Skip to content

Commit

Permalink
enabled json
Browse files Browse the repository at this point in the history
  • Loading branch information
siamaksade committed Jun 9, 2016
1 parent c987a3e commit b7eedce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ REST Endpoints on OpenShift
* Get a task by id

```
curl -u 'redhat:redhat1!' -H "Accept: application/xml" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks/1
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks/1
```

* Get all user tasks

```
curl -u 'redhat:redhat1!' -H "Accept: application/xml" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks
```

* Delete a task by id
Expand Down
3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@
<artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSON: uncomment to include json support (note json is not part of the JAX-RS standard) -->
<!--
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.1.GA</version>
<scope>provided</scope>
</dependency>
-->

<!-- Import the EJB API, we use provided scope as the API is included in JBoss EAP 6 -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.jboss.as.quickstarts.tasksrs.model;

// JSON: uncomment to include json support (note json is not part of the JAX-RS standard)
//import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnore;

import static javax.persistence.GenerationType.IDENTITY;

Expand Down Expand Up @@ -72,8 +72,7 @@ public void setId(Long id) {
}

@XmlTransient
// JSON: uncomment to include json support (note json is not part of the JAX-RS standard)
// @JsonIgnore
@JsonIgnore
public User getOwner() {
return owner;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ public void deleteTaskById(@Context SecurityContext context, @PathParam("id") Lo

@GET
@Path("tasks/{id}")
// JSON: include "application/json" in the @Produces annotation to include json support
//@Produces({ "application/xml", "application/json" })
@Produces({ "application/xml" })
@Produces({ "application/xml", "application/json" })
public Task getTaskById(@Context SecurityContext context, @PathParam("id") Long id) {
User user = getUser(context);

Expand All @@ -91,18 +89,14 @@ public Task getTaskById(@Context SecurityContext context, @PathParam("id") Long

@GET
@Path("tasks/{title}")
// JSON: include "application/json" in the @Produces annotation to include json support
//@Produces({ "application/xml", "application/json" })
@Produces({ "application/xml" })
@Produces({ "application/xml", "application/json" })
public List<Task> getTasksByTitle(@Context SecurityContext context, @PathParam("title") String title) {
return getTasks(getUser(context), title);
}

@GET
@Path("tasks")
// JSON: include "application/json" in the @Produces annotation to include json support
//@Produces({ "application/xml", "application/json" })
@Produces({ "application/xml" })
@Produces({ "application/xml", "application/json" })
public List<Task> getTasks(@Context SecurityContext context) {
return getTasks(getUser(context));
}
Expand Down

0 comments on commit b7eedce

Please sign in to comment.