Examples of PetClinicException


Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

        out.write(buffer, 0, len);
      }
      vetPhotos.put(id, out.toByteArray());
    }
    catch (IOException e) {
      throw new PetClinicException(e.getMessage());
    }
  }
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    brochure.setMetaData(metaData);
    try {
      brochure.setData(new DataHandler(new ByteArrayDataSource(data, format)));
    }
    catch (IOException e) {
      throw new PetClinicException(e.getMessage());
    }
    return brochure;
  }
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    if (format == null) {
      format = "application/pdf";
    }

    if (animalType == null) {
      throw new PetClinicException("animal type must be specified.");
    }

    animalType = animalType.trim();
    if (animalType.length() == 0) {
      throw new PetClinicException("animal type must be specified.");
    }

    InputStream data = getClass().getResourceAsStream(animalType + "-brochure." + format);
    if (data == null) {
      throw new NotFoundException("A brochure for animal " + animalType + " in format " + format + " was not found.");
    }
    if ("text/html".equalsIgnoreCase(format)) {
      data = getClass().getResourceAsStream("clinic-brochure.html");
    }
    else if ("text/plain".equalsIgnoreCase(format)) {
      data = getClass().getResourceAsStream("clinic-brochure.txt");
    }
    else {
      throw new PetClinicException("Unknown brochure format: " + format);
    }

    AnimalBrochure brochure = new AnimalBrochure();
    brochure.setContentType(format);
    brochure.setContent(data);
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    return petTypes.values();
  }

  public Collection<Owner> findOwners(String lastName) throws PetClinicException {
    if ((lastName == null) || ("".equals(lastName))) {
      throw new PetClinicException("last name must be specified.");
    }
    ArrayList<Owner> owners = new ArrayList<Owner>();
    for (Owner owner : this.owners.values()) {
      if (lastName.equalsIgnoreCase(owner.getLastName())) {
        owners.add(owner);
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    return owners;
  }

  public Owner loadOwner(int id) throws PetClinicException {
    if (!owners.containsKey(id)) {
      throw new PetClinicException("Unknown owner: " + id);
    }

    return owners.get(id);
  }
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    return owners.get(id);
  }

  public Pet loadPet(int id) throws PetClinicException {
    if (!pets.containsKey(id)) {
      throw new PetClinicException("Unknown pet: " + id);
    }

    return pets.get(id);
  }
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    return pets.get(id);
  }

  public void storeOwner(Owner owner) throws PetClinicException {
    if (owner == null) {
      throw new PetClinicException("An owner must be supplied.");
    }

    if (owner.getPetIds() != null) {
      for (Integer petId : owner.getPetIds()) {
        if (!pets.containsKey(petId)) {
          throw new PetClinicException("Unknown pet id: " + petId);
        }
      }
    }

    if (owner.getId() == null) {
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    this.owners.put(owner.getId(), owner);
  }

  public void storePet(Pet pet) throws PetClinicException {
    if (pet == null) {
      throw new PetClinicException("An pet must be supplied.");
    }

    if (pet.getOwnerId() == null) {
      throw new PetClinicException("An owner must be supplied for a pet.");
    }

    if (!owners.containsKey(pet.getOwnerId())) {
      throw new PetClinicException("Unknown owner id: " + pet.getOwnerId());
    }

    if (pet.getId() == null) {
      pet.setId(pet.hashCode());
    }
View Full Code Here

Examples of org.codehaus.enunciate.samples.petclinic.services.PetClinicException

    owner.getPetIds().add(pet.getId());
  }

  public void storeVisit(Visit visit) throws PetClinicException {
    if (visit == null) {
      throw new PetClinicException("A visit must be supplied.");
    }

    if (visit.getPetId() == null) {
      throw new PetClinicException("A pet id must be supplied.");
    }

    if (!pets.containsKey(visit.getPetId())) {
      throw new PetClinicException("Unknown pet id: " + visit.getPetId());
    }

    visit.setId(visit.hashCode());
    Pet pet = pets.get(visit.getPetId());
    if (pet.getVisits() == null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.