// Path: sample-web-app/src/main/java/com/example/exceptions/PersonAlreadyExistsException.java
// public class PersonAlreadyExistsException extends WebApplicationException {
// 	private static final long serialVersionUID = 6817489620338221395L;
// 
// 	public PersonAlreadyExistsException( final String email ) {
// 		super(
// 			Response
// 				.status( Status.CONFLICT )
// 				.entity( "Person already exists: " + email )
// 				.build()
// 		);
// 	}
// }
// 
// Path: sample-web-app/src/main/java/com/example/exceptions/PersonNotFoundException.java
// public class PersonNotFoundException extends WebApplicationException {
// 	private static final long serialVersionUID = -2894269137259898072L;
// 	
// 	public PersonNotFoundException( final String email ) {
// 		super(
// 			Response
// 				.status( Status.NOT_FOUND )
// 				.entity( "Person not found: " + email )
// 				.build()
// 		);
// 	}
// }
// 
// Path: sample-web-app/src/main/java/com/example/model/Person.java
// public class Person {
// 	private String email;
// 	private String firstName;
// 	private String lastName;
// 		
// 	public Person() {
// 	}
// 	
// 	public Person( final String email ) {
// 		this.email = email;
// 	}
// 	
// 	public Person( final String firstName, final String lastName ) {
// 		this.firstName = firstName;
// 		this.lastName = lastName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public void setEmail( final String email ) {
// 		this.email = email;
// 	}
// 		
// 	public String getFirstName() {
// 		return firstName;
// 	}
// 	
// 	public String getLastName() {
// 		return lastName;
// 	}
// 	
// 	public void setFirstName( final String firstName ) {
// 		this.firstName = firstName;
// 	}
// 	
// 	public void setLastName( final String lastName ) {
// 		this.lastName = lastName;
// 	}		
// }


import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.stereotype.Service;
import com.example.exceptions.PersonAlreadyExistsException;
import com.example.exceptions.PersonNotFoundException;
import com.example.model.Person;
package com.example.services;




@Service
public class PeopleService {
	private final ConcurrentMap< String, Person > persons = new ConcurrentHashMap< String, Person >(); 
	
	public Collection< Person > getPeople( int page, int pageSize ) {
		final Collection< Person > slice = new ArrayList< Person >( pageSize );
		
        final Iterator< Person > iterator = persons.values().iterator();
        for( int i = 0; slice.size() < pageSize && iterator.hasNext(); ) {
        	if( ++i > ( ( page - 1 ) * pageSize ) ) {
        		slice.add( iterator.next() );
        	}
        }
		
		return slice;
	}
	
	public Person getByEmail( final String email ) {
		final Person person = persons.get( email );
		
		if( person == null ) {
// Path: sample-web-app/src/main/java/com/example/exceptions/PersonAlreadyExistsException.java
// public class PersonAlreadyExistsException extends WebApplicationException {
// 	private static final long serialVersionUID = 6817489620338221395L;
// 
// 	public PersonAlreadyExistsException( final String email ) {
// 		super(
// 			Response
// 				.status( Status.CONFLICT )
// 				.entity( "Person already exists: " + email )
// 				.build()
// 		);
// 	}
// }
// 
// Path: sample-web-app/src/main/java/com/example/exceptions/PersonNotFoundException.java
// public class PersonNotFoundException extends WebApplicationException {
// 	private static final long serialVersionUID = -2894269137259898072L;
// 	
// 	public PersonNotFoundException( final String email ) {
// 		super(
// 			Response
// 				.status( Status.NOT_FOUND )
// 				.entity( "Person not found: " + email )
// 				.build()
// 		);
// 	}
// }
// 
// Path: sample-web-app/src/main/java/com/example/model/Person.java
// public class Person {
// 	private String email;
// 	private String firstName;
// 	private String lastName;
// 		
// 	public Person() {
// 	}
// 	
// 	public Person( final String email ) {
// 		this.email = email;
// 	}
// 	
// 	public Person( final String firstName, final String lastName ) {
// 		this.firstName = firstName;
// 		this.lastName = lastName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public void setEmail( final String email ) {
// 		this.email = email;
// 	}
// 		
// 	public String getFirstName() {
// 		return firstName;
// 	}
// 	
// 	public String getLastName() {
// 		return lastName;
// 	}
// 	
// 	public void setFirstName( final String firstName ) {
// 		this.firstName = firstName;
// 	}
// 	
// 	public void setLastName( final String lastName ) {
// 		this.lastName = lastName;
// 	}		
// }


// Path: sample-web-app/src/main/java/com/example/services/PeopleService.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.stereotype.Service;
import com.example.exceptions.PersonAlreadyExistsException;
import com.example.exceptions.PersonNotFoundException;
import com.example.model.Person;

package com.example.services;




@Service
public class PeopleService {
	private final ConcurrentMap< String, Person > persons = new ConcurrentHashMap< String, Person >(); 
	
	public Collection< Person > getPeople( int page, int pageSize ) {
		final Collection< Person > slice = new ArrayList< Person >( pageSize );
		
        final Iterator< Person > iterator = persons.values().iterator();
        for( int i = 0; slice.size() < pageSize && iterator.hasNext(); ) {
        	if( ++i > ( ( page - 1 ) * pageSize ) ) {
        		slice.add( iterator.next() );
        	}
        }
		
		return slice;
	}
	
	public Person getByEmail( final String email ) {
		final Person person = persons.get( email );
		
		if( person == null ) {
			throw new PersonNotFoundException( email );