public int deleteAddresssByUser(UserType user) throws FactoryException {
   long[] ids =
       getIdByField(
           new QueryField[] {QueryFields.getFieldOwner(user.getId())},
           user.getOrganization().getId());
   return deleteAddresssByIds(ids, user.getOrganization());
 }
 public AddressType newAddress(UserType user, DirectoryGroupType group) throws ArgumentException {
   if (user == null || user.getDatabaseRecord() == false)
     throw new ArgumentException("Invalid owner");
   AddressType obj = new AddressType();
   obj.setLocationType(LocationEnumType.UNKNOWN);
   obj.setOrganization(group.getOrganization());
   obj.setOwnerId(user.getId());
   obj.setGroup(group);
   obj.setNameType(NameEnumType.ADDRESS);
   return obj;
 }
  public AddressType newAddress(UserType user, AddressType parentAddress) throws ArgumentException {
    if (user == null || user.getDatabaseRecord() == false)
      throw new ArgumentException("Invalid owner");

    AddressType obj = newAddress(user, parentAddress.getGroup());

    return obj;
  }
 public OperationResponseEnumType operate(
     final PatternType pattern, FactType sourceFact, final FactType referenceFact) {
   if (sourceFact.getSourceUrn() == null) {
     logger.error("Invalid argument");
     return OperationResponseEnumType.ERROR;
   }
   UserType u = read(sourceFact, referenceFact);
   if (u == null) {
     logger.error(
         "Failed to find user "
             + sourceFact.getSourceUrn()
             + " in organization "
             + referenceFact.getOrganization().getName());
     return OperationResponseEnumType.FAILED;
   }
   logger.info(
       "Found user "
           + sourceFact.getSourceUrn()
           + " in organization "
           + referenceFact.getOrganization().getName()
           + " having user id "
           + u.getId());
   return OperationResponseEnumType.SUCCEEDED;
 }