CleanUp Code

This commit is contained in:
giuseppe.bueti 2016-02-07 20:55:46 +01:00 committed by Giuseppe Bueti
parent 783dc6bdc2
commit 71793635d3
9 changed files with 7 additions and 64 deletions

View File

@ -36,7 +36,7 @@
</build>
<dependencies>
<!-- core library -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
@ -101,5 +101,4 @@
</dependencies>
</project>

View File

@ -1,7 +1,6 @@
package com.baeldung.client;
import com.baeldung.model.Movie;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -1,11 +1,9 @@
package com.baeldung.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "movie", propOrder = {
"actors",

View File

@ -1,7 +1,6 @@
package com.baeldung.server;
import com.baeldung.model.Movie;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@ -11,23 +10,21 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Path("/movies")
public class MovieCrudService {
private Map<String,Movie> inventory = new HashMap<String, Movie>();
@GET
@Path("/getinfo")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){
public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){
System.out.println("*** Calling getinfo for a given ImdbID***");
if(inventory.containsKey(imdbID)){
return inventory.get(imdbID);
if(inventory.containsKey(imdbId)){
return inventory.get(imdbId);
}else return null;
}
@ -70,16 +67,16 @@ public class MovieCrudService {
@DELETE
@Path("/deletemovie")
public Response deleteMovie(@QueryParam("imdbId") String imdbID){
public Response deleteMovie(@QueryParam("imdbId") String imdbId){
System.out.println("*** Calling deleteMovie ***");
if (null==inventory.get(imdbID)){
if (null==inventory.get(imdbId)){
return Response.status(Response.Status.NOT_FOUND)
.entity("Movie is not in the database.\nUnable to Delete").build();
}
inventory.remove(imdbID);
inventory.remove(imdbId);
return Response.status(Response.Status.OK).build();
}
@ -93,6 +90,4 @@ public class MovieCrudService {
}
}

View File

@ -1,19 +1,11 @@
package com.baeldung.server;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Created by Admin on 29/01/2016.
*/
@ApplicationPath("/rest")
public class RestEasyServices extends Application {

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="movie">
<xs:sequence>
<xs:element name="actors" type="xs:string" minOccurs="0"/>
<xs:element name="awards" type="xs:string" minOccurs="0"/>
<xs:element name="country" type="xs:string" minOccurs="0"/>
<xs:element name="director" type="xs:string" minOccurs="0"/>
<xs:element name="genre" type="xs:string" minOccurs="0"/>
<xs:element name="imdbID" type="xs:string" minOccurs="0"/>
<xs:element name="imdbRating" type="xs:string" minOccurs="0"/>
<xs:element name="imdbVotes" type="xs:string" minOccurs="0"/>
<xs:element name="language" type="xs:string" minOccurs="0"/>
<xs:element name="metascore" type="xs:string" minOccurs="0"/>
<xs:element name="plot" type="xs:string" minOccurs="0"/>
<xs:element name="poster" type="xs:string" minOccurs="0"/>
<xs:element name="rated" type="xs:string" minOccurs="0"/>
<xs:element name="released" type="xs:string" minOccurs="0"/>
<xs:element name="response" type="xs:string" minOccurs="0"/>
<xs:element name="runtime" type="xs:string" minOccurs="0"/>
<xs:element name="title" type="xs:string" minOccurs="0"/>
<xs:element name="type" type="xs:string" minOccurs="0"/>
<xs:element name="writer" type="xs:string" minOccurs="0"/>
<xs:element name="year" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -5,12 +5,9 @@
<display-name>RestEasy Example</display-name>
<!-- needed only if you want prepend a relative path to your services -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
</web-app>

View File

@ -1,7 +0,0 @@
package baeldung.client;
/**
* Created by Admin on 29/01/2016.
*/
public class RestEasyClient {
}

View File

@ -10,7 +10,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.junit.Before;
import org.junit.Test;
import javax.naming.NamingException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;