public PointOfContactBean findPointOfContactById(String pocId) throws PointOfContactException {
   PointOfContactBean pocBean = null;
   try {
     PointOfContact poc = helper.findPointOfContactById(pocId);
     pocBean = new PointOfContactBean(poc);
   } catch (Exception e) {
     String err = "Problem finding point of contact for the given id.";
     logger.error(err, e);
     throw new PointOfContactException(err, e);
   }
   return pocBean;
 }
  public void savePointOfContact(PointOfContactBean pocBean)
      throws PointOfContactException, NoAccessException {
    if (user == null) {
      throw new NoAccessException();
    }
    try {
      PointOfContact dbPointOfContact = null;
      Long oldPOCId = null;
      String oldOrgName = null;
      Boolean newPOC = true;
      Boolean newOrg = true;
      CaNanoLabApplicationService appService =
          (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
      PointOfContact domainPOC = pocBean.getDomain();
      Organization domainOrg = domainPOC.getOrganization();
      // get existing organization from database and reuse ID,
      // created by and created date
      // address information will be updated
      Organization dbOrganization = helper.findOrganizationByName(domainOrg.getName());
      if (dbOrganization != null) {
        domainOrg.setId(dbOrganization.getId());
        domainOrg.setCreatedBy(dbOrganization.getCreatedBy());
        domainOrg.setCreatedDate(dbOrganization.getCreatedDate());
        newOrg = false;
      }
      // create a new org if not an existing one
      else {
        domainOrg.setId(null);
      }
      // if point of contact has no ID
      if (domainPOC.getId() == null) {
        // check if org name, first name and last name matches existing
        // one
        dbPointOfContact =
            helper.findPointOfContactByNameAndOrg(
                domainPOC.getFirstName(),
                domainPOC.getLastName(),
                domainPOC.getOrganization().getName());
        // if found, reuse ID, created_date and created_by
        if (dbPointOfContact != null) {
          domainPOC.setId(dbPointOfContact.getId());
          domainPOC.setCreatedDate(dbPointOfContact.getCreatedDate());
          domainPOC.setCreatedBy(dbPointOfContact.getCreatedBy());
          newPOC = false;
        }
      } else {
        // check if organization is changed
        dbPointOfContact = helper.findPointOfContactById(domainPOC.getId().toString());
        Organization dbOrg = dbPointOfContact.getOrganization();
        // if organization information is changed, create a new POC
        if (!dbOrg.getName().equals(domainOrg.getName())) {
          oldPOCId = domainPOC.getId();
          oldOrgName = dbOrg.getName();
          domainPOC.setId(null);
          newPOC = true;
        }
        // if name information is changed, create a new POC
        else if (domainPOC.getFirstName() != null
                && !domainPOC.getFirstName().equalsIgnoreCase(dbPointOfContact.getFirstName())
            || domainPOC.getLastName() != null
                && !domainPOC.getLastName().equalsIgnoreCase(dbPointOfContact.getLastName())) {
          newPOC = true;
        } else {
          domainPOC.setId(dbPointOfContact.getId());
          domainPOC.setCreatedBy(dbPointOfContact.getCreatedBy());
          domainPOC.setCreatedDate(dbPointOfContact.getCreatedDate());
          newPOC = false;
        }
      }
      appService.saveOrUpdate(domainPOC);

      if (newPOC) {
        this.saveAccessibility(AccessibilityBean.CSM_PUBLIC_ACCESS, domainPOC.getId().toString());
      }
      if (newOrg) {
        this.saveAccessibility(
            AccessibilityBean.CSM_PUBLIC_ACCESS, domainPOC.getOrganization().getId().toString());
      }
    } catch (Exception e) {
      String err = "Error in saving the PointOfContact.";
      logger.error(err, e);
      throw new PointOfContactException(err, e);
    }
  }