@Override
 public void removeRepresentations() throws ResourceException {
   Phonebook privatePhonebook = m_phonebookManager.getPrivatePhonebook(getUser());
   if (privatePhonebook != null) {
     Collection<PhonebookEntry> entries = privatePhonebook.getEntries();
     ArrayList<String> ids = new ArrayList<String>();
     for (PhonebookEntry entry : entries) {
       ids.add(String.valueOf(entry.getId()));
     }
     if (ids.contains(m_entryId)) {
       PhonebookEntry entry = m_phonebookManager.getPhonebookEntry(Integer.parseInt(m_entryId));
       m_phonebookManager.deletePhonebookEntry(entry);
     }
   }
 }
 @Override
 public Representation represent(Variant variant) throws ResourceException {
   Phonebook privatePhonebook = m_phonebookManager.getPrivatePhonebook(getUser());
   if (privatePhonebook != null) {
     Collection<PhonebookEntry> entries = privatePhonebook.getEntries();
     ArrayList<String> ids = new ArrayList<String>();
     for (PhonebookEntry entry : entries) {
       ids.add(String.valueOf(entry.getId()));
     }
     if (ids.contains(m_entryId)) {
       PhonebookEntry entry = m_phonebookManager.getPhonebookEntry(Integer.parseInt(m_entryId));
       PhonebookEntry reprEntry = (PhonebookEntry) entry.duplicate();
       return new PhonebookEntryRepresentation(variant.getMediaType(), reprEntry);
     }
   }
   return null;
 }
  @Override
  public void acceptRepresentation(Representation entity) throws ResourceException {
    PhonebookEntryRepresentation representation = new PhonebookEntryRepresentation(entity);
    PhonebookEntry newEntry = representation.getObject();
    if (!validatePhonebookEntry(newEntry)) {
      return;
    }

    if (m_phonebookManager.getDuplicatePhonebookEntry(newEntry, getUser()) != null) {
      setDuplicateEntryStatus();
      return;
    }

    User user = getUser();
    Phonebook privatePhonebook = m_phonebookManager.getPrivatePhonebookCreateIfRequired(user);
    newEntry.setPhonebook(privatePhonebook);
    (privatePhonebook.getEntries()).add(newEntry);
    m_phonebookManager.savePhonebook(privatePhonebook);
  }