Esempio n. 1
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (!(obj instanceof TaskData)) return false;
    TaskData other = (TaskData) obj;

    if (actualOwner == null) {
      if (other.actualOwner != null) return false;
    } else if (!actualOwner.equals(other.actualOwner)) {
      return false;
    }

    if (createdBy == null) {
      if (other.createdBy != null) return false;
    } else if (!createdBy.equals(other.createdBy)) {
      return false;
    }

    if (createdOn == null) {
      if (other.createdOn != null) return false;
    } else if (createdOn.getTime() != other.createdOn.getTime()) return false;
    if (expirationTime == null) {
      if (other.expirationTime != null) return false;
    } else if (expirationTime.getTime() != other.expirationTime.getTime()) return false;
    if (skipable != other.skipable) return false;
    if (workItemId != other.workItemId) return false;
    if (status == null) {
      if (other.status != null) return false;
    } else if (!status.equals(other.status)) return false;
    if (previousStatus == null) {
      if (other.previousStatus != null) return false;
    } else if (!previousStatus.equals(other.previousStatus)) return false;
    if (activationTime == null) {
      if (other.activationTime != null) return false;
    } else if (activationTime.getTime() != other.activationTime.getTime()) return false;

    if (workItemId != other.workItemId) return false;

    if (documentAccessType == null) {
      if (other.documentAccessType != null) return false;
    } else if (!documentAccessType.equals(other.documentAccessType)) return false;

    if (documentContentId != other.documentContentId) return false;
    if (documentType == null) {
      if (other.documentType != null) return false;
    } else if (!documentType.equals(other.documentType)) return false;
    // I think this is OK!
    if (parentId != other.parentId) return false;

    return CollectionUtils.equals(attachments, other.attachments)
        && CollectionUtils.equals(comments, other.comments);
  }
Esempio n. 2
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof RandoPair)) return false;

    RandoPair randoPair = (RandoPair) o;

    if (stranger != null ? !stranger.equals(randoPair.stranger) : randoPair.stranger != null)
      return false;
    if (user != null ? !user.equals(randoPair.user) : randoPair.user != null) return false;

    return true;
  }
 private List<User> parseUsers(JSONArray array) {
   List<User> usersToInsert = new ArrayList<User>();
   if (array != null) {
     for (int i = 0; i < array.length(); ++i) {
       JSONObject object = array.optJSONObject(i);
       if (object != null) {
         User user = AsyncUsersFetcher.fromJson(object);
         String remoteId = user.getDailymotionId();
         if (!mLocalUsers.containsKey(remoteId)) {
           user.setNew(mLocalUsers.size() > 0); // considered
           // new if
           // existing
           // vids.
           usersToInsert.add(user); // need insertion, not
           // present locally.
         } else {
           if (!user.equals(mLocalUsers.get(remoteId))) {
             usersToInsert.add(user); // need insertion, been
             // updated
           }
           mLocalUsers.remove(remoteId);
         }
         mFetchedUsers.add(user);
       }
     }
   }
   return usersToInsert;
 }
Esempio n. 4
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (!(obj instanceof MirexNote)) return false;

    MirexNote other = (MirexNote) obj;
    if (author == null) {
      if (other.author != null) return false;
    } else if (!author.equals(other.author)) return false;
    if (content == null) {
      if (other.content != null) return false;
    } else if (!content.equals(other.content)) return false;
    if (createTime == null) {
      if (other.createTime != null) return false;
    } else if (!createTime.equals(other.createTime)) return false;
    if (id == null) {
      if (other.id != null) return false;
    } else if (!id.equals(other.id)) return false;
    if (submission == null) {
      if (other.submission != null) return false;
    } else if (!submission.equals(other.submission)) return false;
    if (type == null) {
      if (other.type != null) return false;
    } else if (!type.equals(other.type)) return false;
    return true;
  }
 private boolean isUserOwner(User user, User owner) {
   return (user != null && owner != null && owner.equals(user))
       || (owner == null
           && user
               == null); // riga modificata per permettere di listare i progetti creati da utenti
                         // guest
 }
Esempio n. 6
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Lot lot = (Lot) o;

    if (item != null ? !item.equals(lot.item) : lot.item != null) return false;
    if (owner != null ? !owner.equals(lot.owner) : lot.owner != null) return false;
    if (datePlaced != null ? !datePlaced.equals(lot.datePlaced) : lot.datePlaced != null)
      return false;
    if (dateEnd != null ? !dateEnd.equals(lot.dateEnd) : lot.dateEnd != null) return false;
    if (startPrice != null ? !startPrice.equals(lot.startPrice) : lot.startPrice != null)
      return false;
    if (buyer != null ? !buyer.equals(lot.buyer) : lot.buyer != null) return false;
    return !(currentPrice != null
        ? !currentPrice.equals(lot.currentPrice)
        : lot.currentPrice != null);
  }
Esempio n. 7
0
  /** Test hashCode() and equals(obj). */
  @Test
  public final void testHashCodeEquals() {
    User user1 = new User(TEST_USER1);
    User user2 = new User(TEST_USER1);
    User user3 = new User(TEST_USER2);

    // Just the name is considered
    Assert.assertTrue(user1.equals(user2));
    Assert.assertTrue(user1.equals(user2));
    Assert.assertFalse(user1.equals(user3));

    // Test behavior in hashed collections
    Set<User> users = new HashSet<User>();
    users.add(user1);
    users.add(user2);
    Assert.assertTrue(users.size() == 1);
    users.add(user3);
    Assert.assertTrue(users.size() == 2);
  }
  @Test
  @Ignore("write a private equals method to compare both users for value-equality")
  public void compare_returned_user_with_database_user() {
    createFullUser("dma");
    createUpdateUserWithMultiDeleteFields();

    updateUser();

    assertTrue(returnUser.equals(databaseUser));
  }
Esempio n. 9
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   HighSchool other = (HighSchool) obj;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   return true;
 }
Esempio n. 10
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    MailOutMessage that = (MailOutMessage) o;

    if (title != null ? !title.equals(that.title) : that.title != null) return false;
    if (content != null ? !content.equals(that.content) : that.content != null) return false;
    return !(author != null ? !author.equals(that.author) : that.author != null);
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Notification that = (Notification) o;

    if (message != null ? !message.equals(that.message) : that.message != null) return false;
    return userNotified != null
        ? userNotified.equals(that.userNotified)
        : that.userNotified == null;
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (!(obj instanceof UserRoleActivation)) return false;
   UserRoleActivation other = (UserRoleActivation) obj;
   if (role == null) {
     if (other.role != null) return false;
   } else if (!role.equals(other.role)) return false;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   return true;
 }
Esempio n. 13
0
 public boolean equals(Object obj) {
   boolean result = false;
   if (this == obj) result = true;
   else if (obj == null) result = false;
   else if (getClass() != obj.getClass()) result = false;
   else if (obj instanceof Session) {
     Session other = (Session) obj;
     result =
         (idSesion == other.getId()
             && currentActiveProject == other.getCurrentActiveProject()
             && user.equals(other.getUser()));
   }
   return result;
 }
Esempio n. 14
0
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   UserRole other = (UserRole) obj;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (role == null) {
     if (other.role != null) return false;
   } else if (!role.equals(other.role)) return false;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   return true;
 }
Esempio n. 15
0
  @Override
  public boolean onCommand(Sender sender, String[] args) {

    if (!sender.isAdmin()) {
      sender.sendMessageServer("Tu n'a pas la permisions");
      return true;
    }

    if (args.length >= 1) {
      User u = User.getUser(args[0]);
      if (u != null && !u.equals(sender) && !u.isAdmin()) {
        u.kick();
        return true;
      }
    }
    return false;
  }
Esempio n. 16
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Conta other = (Conta) obj;
   if (login == null) {
     if (other.login != null) return false;
   } else if (!login.equals(other.login)) return false;
   if (senha == null) {
     if (other.senha != null) return false;
   } else if (!senha.equals(other.senha)) return false;
   if (usuario == null) {
     if (other.usuario != null) return false;
   } else if (!usuario.equals(other.usuario)) return false;
   return true;
 }
Esempio n. 17
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof CallListCompany)) return false;

    CallListCompany that = (CallListCompany) o;

    if (callList != null ? !callList.equals(that.callList) : that.callList != null) return false;
    if (company != null ? !company.equals(that.company) : that.company != null) return false;
    if (event != null ? !event.equals(that.event) : that.event != null) return false;
    if (lastDateUpdate != null
        ? !lastDateUpdate.equals(that.lastDateUpdate)
        : that.lastDateUpdate != null) return false;
    if (status != null ? !status.equals(that.status) : that.status != null) return false;
    if (user != null ? !user.equals(that.user) : that.user != null) return false;

    return true;
  }
Esempio n. 18
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   UserSchedule other = (UserSchedule) obj;
   if (idDaysOfWeek == null) {
     if (other.idDaysOfWeek != null) return false;
   } else if (!idDaysOfWeek.equals(other.idDaysOfWeek)) return false;
   if (openTime == null) {
     if (other.openTime != null) return false;
   } else if (!openTime.equals(other.openTime)) return false;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   if (userSchedulePK == null) {
     if (other.userSchedulePK != null) return false;
   } else if (!userSchedulePK.equals(other.userSchedulePK)) return false;
   return true;
 }
Esempio n. 19
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Animal animal = (Animal) o;

    if (id != null ? !id.equals(animal.id) : animal.id != null) return false;
    if (sex != animal.sex) return false;
    if (type != null ? !type.equals(animal.type) : animal.type != null) return false;
    if (size != animal.size) return false;
    if (cites != animal.cites) return false;
    if (breed != null ? !breed.equals(animal.breed) : animal.breed != null) return false;
    if (transpNumber != null
        ? !transpNumber.equals(animal.transpNumber)
        : animal.transpNumber != null) return false;
    if (tokenNumber != null ? !tokenNumber.equals(animal.tokenNumber) : animal.tokenNumber != null)
      return false;
    if (dateOfRegister != null
        ? !dateOfRegister.equals(animal.dateOfRegister)
        : animal.dateOfRegister != null) return false;
    if (dateOfBirth != null ? !dateOfBirth.equals(animal.dateOfBirth) : animal.dateOfBirth != null)
      return false;
    if (dateOfSterilization != null
        ? !dateOfSterilization.equals(animal.dateOfSterilization)
        : animal.dateOfSterilization != null) return false;
    if (dateOfFacebook != null
        ? !dateOfFacebook.equals(animal.dateOfFacebook)
        : animal.dateOfFacebook != null) return false;
    if (dateOfTwitter != null
        ? !dateOfTwitter.equals(animal.dateOfTwitter)
        : animal.dateOfTwitter != null) return false;
    if (color != null ? !color.equals(animal.color) : animal.color != null) return false;
    if (description != null ? !description.equals(animal.description) : animal.description != null)
      return false;
    if (user != null ? !user.equals(animal.user) : animal.user != null) return false;
    if (address != null ? !address.equals(animal.address) : animal.address != null) return false;
    if (active != null ? !active.equals(animal.active) : animal.active != null) return false;
    if (image != null ? !image.equals(animal.image) : animal.image != null) return false;
    return !(service != null ? !service.equals(animal.service) : animal.service != null);
  }
Esempio n. 20
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   UserPreference other = (UserPreference) obj;
   if (createdDate == null) {
     if (other.createdDate != null) return false;
   } else if (!createdDate.equals(other.createdDate)) return false;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (type == null) {
     if (other.type != null) return false;
   } else if (!type.equals(other.type)) return false;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   if (value == null) {
     if (other.value != null) return false;
   } else if (!value.equals(other.value)) return false;
   return true;
 }
Esempio n. 21
0
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   Order other = (Order) obj;
   if (changeValue == null) {
     if (other.changeValue != null) {
       return false;
     }
   } else if (!changeValue.equals(other.changeValue)) {
     return false;
   }
   if (closeDate == null) {
     if (other.closeDate != null) {
       return false;
     }
   } else if (!closeDate.equals(other.closeDate)) {
     return false;
   }
   if (discount == null) {
     if (other.discount != null) {
       return false;
     }
   } else if (!discount.equals(other.discount)) {
     return false;
   }
   if (id == null) {
     if (other.id != null) {
       return false;
     }
   } else if (!id.equals(other.id)) {
     return false;
   }
   if (idCustomer == null) {
     if (other.idCustomer != null) {
       return false;
     }
   } else if (!idCustomer.equals(other.idCustomer)) {
     return false;
   }
   if (idTable == null) {
     if (other.idTable != null) {
       return false;
     }
   } else if (!idTable.equals(other.idTable)) {
     return false;
   }
   if (openDate == null) {
     if (other.openDate != null) {
       return false;
     }
   } else if (!openDate.equals(other.openDate)) {
     return false;
   }
   if (orderStatus == null) {
     if (other.orderStatus != null) {
       return false;
     }
   } else if (!orderStatus.equals(other.orderStatus)) {
     return false;
   }
   if (product == null) {
     if (other.product != null) {
       return false;
     }
   } else if (!product.equals(other.product)) {
     return false;
   }
   if (productType == null) {
     if (other.productType != null) {
       return false;
     }
   } else if (!productType.equals(other.productType)) {
     return false;
   }
   if (receivedValue == null) {
     if (other.receivedValue != null) {
       return false;
     }
   } else if (!receivedValue.equals(other.receivedValue)) {
     return false;
   }
   if (sObservacao == null) {
     if (other.sObservacao != null) {
       return false;
     }
   } else if (!sObservacao.equals(other.sObservacao)) {
     return false;
   }
   if (totalValue == null) {
     if (other.totalValue != null) {
       return false;
     }
   } else if (!totalValue.equals(other.totalValue)) {
     return false;
   }
   if (user == null) {
     if (other.user != null) {
       return false;
     }
   } else if (!user.equals(other.user)) {
     return false;
   }
   return true;
 }
Esempio n. 22
0
  /**
   * Example of an equals method.
   *
   * <pre>
   * returns true when attributes of comparing object and this object are null or equal.
   * Attributes that are compared are :
   *  All
   * <b>
   * NOTE: This is specific to how systems use IDMEF messages and
   *       what it means when two objects are equivalent.  For
   *       example, equivalence may mean a subset of the objects
   *       attributes.  It's advised that this method is modified
   *       for your particular environment.
   * </b>
   * </pre>
   */
  public boolean equals(Object anObject) {
    boolean equals = false;
    boolean arenodeequal = false;
    boolean areprocessequal = false;
    boolean areserviceequal = false;
    boolean areuserequal = false;
    boolean aredecoyequal = false;
    boolean areNIequal = false;
    Target inTarget;
    if (anObject == null) {
      return equals;
    }
    if (anObject instanceof Target) {
      inTarget = (Target) anObject;
      IDMEF_Node myNode;
      IDMEF_Node inNode;
      myNode = this.getNode();
      inNode = inTarget.getNode();
      if ((myNode != null) && (inNode != null)) {
        if (myNode.equals(inNode)) {
          arenodeequal = true;
        }
      } else if ((myNode == null) && (inNode == null)) {
        arenodeequal = true;
      }
      IDMEF_Process myProcess;
      IDMEF_Process inProcess;
      myProcess = this.getProcess();
      inProcess = inTarget.getProcess();
      if ((myProcess != null) && (inProcess != null)) {
        if (myProcess.equals(inProcess)) {
          areprocessequal = true;
        }
      } else if ((myProcess == null) && (inProcess == null)) {
        areprocessequal = true;
      }
      Service myService;
      Service inService;
      myService = this.getService();
      inService = inTarget.getService();
      if ((myService != null) && (inService != null)) {
        if (myService.equals(inService)) {
          areserviceequal = true;
        }
      } else if ((myService == null) && (inService == null)) {
        areserviceequal = true;
      }
      User myUser;
      User inUser;
      myUser = this.getUser();
      inUser = inTarget.getUser();
      if ((myUser != null) && (inUser != null)) {
        if (myUser.equals(inUser)) {
          areuserequal = true;
        }
      } else if ((myUser == null) && (inUser == null)) {
        areuserequal = true;
      }
      String myvalue;
      String invalue;
      myvalue = this.getDecoy();
      invalue = inTarget.getDecoy();
      if ((myvalue != null) && (invalue != null)) {
        if (myvalue.trim().equals(invalue.trim())) {
          aredecoyequal = true;
        }
      } else if ((myvalue == null) && (invalue == null)) {
        aredecoyequal = true;
      }

      myvalue = this.getNetworkInterface();
      invalue = inTarget.getNetworkInterface();
      if ((myvalue != null) && (invalue != null)) {
        if (myvalue.trim().equals(invalue.trim())) {
          areNIequal = true;
        }
      } else if ((myvalue == null) && (invalue == null)) {
        areNIequal = true;
      }

      if (arenodeequal
          && areprocessequal
          && areserviceequal
          && areuserequal
          && aredecoyequal
          && areNIequal) {
        equals = true;
      }
    }
    return equals;
  }
Esempio n. 23
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   Issue other = (Issue) obj;
   if (assignee == null) {
     if (other.assignee != null) {
       return false;
     }
   } else if (!assignee.equals(other.assignee)) {
     return false;
   }
   if (author == null) {
     if (other.author != null) {
       return false;
     }
   } else if (!author.equals(other.author)) {
     return false;
   }
   if (createdOn == null) {
     if (other.createdOn != null) {
       return false;
     }
   } else if (!createdOn.equals(other.createdOn)) {
     return false;
   }
   if (customFields == null) {
     if (other.customFields != null) {
       return false;
     }
   } else if (!customFields.equals(other.customFields)) {
     return false;
   }
   if (description == null) {
     if (other.description != null) {
       return false;
     }
   } else if (!description.equals(other.description)) {
     return false;
   }
   if (doneRatio == null) {
     if (other.doneRatio != null) {
       return false;
     }
   } else if (!doneRatio.equals(other.doneRatio)) {
     return false;
   }
   if (dueDate == null) {
     if (other.dueDate != null) {
       return false;
     }
   } else if (!dueDate.equals(other.dueDate)) {
     return false;
   }
   if (estimatedHours == null) {
     if (other.estimatedHours != null) {
       return false;
     }
   } else if (!estimatedHours.equals(other.estimatedHours)) {
     return false;
   }
   if (id == null) {
     if (other.id != null) {
       return false;
     }
   } else if (!id.equals(other.id)) {
     return false;
   }
   if (journals == null) {
     if (other.journals != null) {
       return false;
     }
   } else if (!journals.equals(other.journals)) {
     return false;
   }
   if (notes == null) {
     if (other.notes != null) {
       return false;
     }
   } else if (!notes.equals(other.notes)) {
     return false;
   }
   if (parentId == null) {
     if (other.parentId != null) {
       return false;
     }
   } else if (!parentId.equals(other.parentId)) {
     return false;
   }
   if (priorityId == null) {
     if (other.priorityId != null) {
       return false;
     }
   } else if (!priorityId.equals(other.priorityId)) {
     return false;
   }
   if (priorityText == null) {
     if (other.priorityText != null) {
       return false;
     }
   } else if (!priorityText.equals(other.priorityText)) {
     return false;
   }
   if (project == null) {
     if (other.project != null) {
       return false;
     }
   } else if (!project.equals(other.project)) {
     return false;
   }
   if (relations == null) {
     if (other.relations != null) {
       return false;
     }
   } else if (!relations.equals(other.relations)) {
     return false;
   }
   if (spentHours == null) {
     if (other.spentHours != null) {
       return false;
     }
   } else if (!spentHours.equals(other.spentHours)) {
     return false;
   }
   if (startDate == null) {
     if (other.startDate != null) {
       return false;
     }
   } else if (!startDate.equals(other.startDate)) {
     return false;
   }
   if (statusId == null) {
     if (other.statusId != null) {
       return false;
     }
   } else if (!statusId.equals(other.statusId)) {
     return false;
   }
   if (statusName == null) {
     if (other.statusName != null) {
       return false;
     }
   } else if (!statusName.equals(other.statusName)) {
     return false;
   }
   if (subject == null) {
     if (other.subject != null) {
       return false;
     }
   } else if (!subject.equals(other.subject)) {
     return false;
   }
   if (tracker == null) {
     if (other.tracker != null) {
       return false;
     }
   } else if (!tracker.equals(other.tracker)) {
     return false;
   }
   if (updatedOn == null) {
     if (other.updatedOn != null) {
       return false;
     }
   } else if (!updatedOn.equals(other.updatedOn)) {
     return false;
   }
   if (attachments == null) {
     if (other.attachments != null) {
       return false;
     }
   } else if (!attachments.equals(other.attachments)) {
     return false;
   }
   return true;
 }
Esempio n. 24
0
 public void broadcast(User user, String userMessage) {
   for (User recipient : users) {
     if (!recipient.equals(user)) recipient.sendMessage(userMessage);
   }
 }
Esempio n. 25
0
  /**
   * This actual CCN loop to send/receive messages. Called by the UI class. This method blocks! If
   * the UI is not multi-threaded, you should start a thread to hold listen().
   *
   * <p>When shutdown() is called, listen() will exit.
   *
   * @throws ConfigurationException
   * @throws IOException
   * @throws MalformedContentNameStringException
   */
  public void listen()
      throws ConfigurationException, IOException, MalformedContentNameStringException,
          RuntimeException {

    // Also publish your keys under the chat "channel name" namespace
    if (_namespace.toString().startsWith("ccnx:/")) {
      UserConfiguration.setDefaultNamespacePrefix(_namespace.toString().substring(5));
    } else {
      UserConfiguration.setDefaultNamespacePrefix(_namespace.toString());
    }

    CCNHandle tempReadHandle = CCNHandle.getHandle();

    // Writing must be on a different handle, to enable us to read back text
    // we have
    // written when nobody else is reading.
    CCNHandle tempWriteHandle = CCNHandle.open();

    _readString = new CCNStringObject(_namespace, (String) null, SaveType.RAW, tempReadHandle);
    _readString.updateInBackground(true);

    String introduction = UserConfiguration.userName() + " has entered " + _namespace;
    _writeString = new CCNStringObject(_namespace, introduction, SaveType.RAW, tempWriteHandle);
    _writeString.save();

    // Publish the user's friendly name as a speaker if needed
    // AND if this topic doesn't already have a speaker!
    if (this.currentUser.isSpeaker()) {
      if (this.userList.getSpeaker() == null
          || this.userList.getSpeaker().equals(this.currentUser)) {
        String friendlyNameNamespaceStr = _namespaceStr + TextConf.SPEAKER_COMPONENT;
        _spkrNamespace =
            KeyProfile.keyName(
                ContentName.fromURI(friendlyNameNamespaceStr), _writeString.getContentPublisher());
        Log.info("**** Speaker Namespace is " + _spkrNamespace);

        // read the string here.....
        _readNameString =
            new CCNStringObject(_spkrNamespace, (String) null, SaveType.RAW, tempReadHandle);
        _readNameString.updateInBackground(true);

        String publishedNameStr = UserConfiguration.userName();
        Log.info("*****I am adding my own speaker name as " + publishedNameStr);
        _writeNameString =
            new CCNStringObject(_spkrNamespace, publishedNameStr, SaveType.RAW, tempWriteHandle);
        _writeNameString.save();
      } else {
        throw new RuntimeException(
            "The conference topic "
                + this.currentTopic.getTopicName()
                + " already has a Speaker ("
                + this.userList.getSpeaker().getUserName()
                + ")!!!");
      }
    } else {
      // If the current user isn't a speaker, then they can't join a conference
      // that doesn't have one (i.e. they can't create a conference)
      if (this.userList.speaker == null) {
        throw new RuntimeException(
            "The conference topic "
                + this.currentTopic.getTopicName()
                + " doesn't have a Speaker yet so it isn't accepting non-Speakers!!!");
      }
    }

    // Publish the user's friendly name under a new ContentName
    String friendlyNameNamespaceStr = _namespaceStr + TextConf.MEMBER_COMPONENT;
    _userNamespace =
        KeyProfile.keyName(
            ContentName.fromURI(friendlyNameNamespaceStr), _writeString.getContentPublisher());
    Log.info("**** Friendly Namespace is " + _userNamespace);

    // read the string here.....
    _readNameString =
        new CCNStringObject(_userNamespace, (String) null, SaveType.RAW, tempReadHandle);
    _readNameString.updateInBackground(true);

    String publishedNameStr = UserConfiguration.userName();
    Log.info("*****I am adding my own friendly name as " + publishedNameStr);
    _writeNameString =
        new CCNStringObject(_userNamespace, publishedNameStr, SaveType.RAW, tempWriteHandle);
    _writeNameString.save();

    try {
      addNameToHash(_writeNameString.getContentPublisher(), _writeNameString.string());
    } catch (IOException e) {
      System.err.println("Unable to read from " + _writeNameString + "for writing to hashMap");
      e.printStackTrace();
    }

    // Need to do synchronization for updates that come in while we're
    // processing last one.

    while (!_finished) {
      try {
        synchronized (_readString) {
          _readString.wait(CYCLE_TIME);
        }
      } catch (InterruptedException e) {
      }

      if (_readString.isSaved()) {
        Timestamp thisUpdate = _readString.getVersion();
        if ((null == _lastUpdate) || thisUpdate.after(_lastUpdate)) {
          Log.info(
              "Got an update from "
                  + _readString.getBaseName().toURIString()
                  + ": "
                  + _readString.getVersion()
                  + "..."
                  + _readString.string());
          _lastUpdate = thisUpdate;

          // lookup friendly name to display for this user.....
          User userFriendlyName =
              getFriendlyName(_readString.getContentPublisher(), tempReadHandle, tempWriteHandle);

          if (!userFriendlyName.equals(this.currentUser)) {
            messageReceived(userFriendlyName, thisUpdate, _readString.string());
          }
        }
      }
    }
  }
Esempio n. 26
0
  @Override
  public List<UserExtSource> consolidateIdentityUsingToken(PerunSession sess, String token)
      throws PerunException {

    Map<String, Object> originalIdentity = requestCache.get(token);

    if (originalIdentity == null) {
      throw new InvalidTokenException(
          "Your token for joining identities is no longer valid. Please retry from the start.");
    }

    User originalUser = (User) originalIdentity.get("user");
    User currentUser = sess.getPerunPrincipal().getUser();

    if (originalUser == null && currentUser == null) {
      IdentityUnknownException ex =
          new IdentityUnknownException(
              "Neither original or current identity is know to Perun. Please use at least one identity known to Perun.");
      ex.setLogin((String) originalIdentity.get("actor"));
      ex.setSource2((String) originalIdentity.get("extSourceName"));
      ex.setSourceType2((String) originalIdentity.get("extSourceType"));
      ex.setLogin2(sess.getPerunPrincipal().getActor());
      ex.setSource2(sess.getPerunPrincipal().getExtSourceName());
      ex.setSourceType2(sess.getPerunPrincipal().getExtSourceType());
      throw ex;
    }

    if (originalIdentity.get("extSourceName").equals(sess.getPerunPrincipal().getExtSourceName())
        && originalIdentity.get("actor").equals(sess.getPerunPrincipal().getActor())
        && originalIdentity
            .get("extSourceType")
            .equals(sess.getPerunPrincipal().getExtSourceType())) {
      IdentityIsSameException ex =
          new IdentityIsSameException(
              "You tried to join same identity with itself. Please try again but select different identity.");
      ex.setLogin(sess.getPerunPrincipal().getActor());
      ex.setSource(sess.getPerunPrincipal().getExtSourceName());
      ex.setSourceType(sess.getPerunPrincipal().getExtSourceType());
      throw ex;
    }

    if (originalUser != null && currentUser != null && originalUser.equals(currentUser)) {
      throw new IdentitiesAlreadyJoinedException("You already have both identities joined.");
    }

    if (originalUser != null && currentUser != null && !originalUser.equals(currentUser)) {
      throw new IdentityAlreadyInUseException(
          "Your identity is already associated with a different user. If you are really the same person, please contact support to help you.",
          originalUser,
          currentUser);
    }

    // merge original identity into current user
    if (originalUser == null) {
      createExtSourceAndUserExtSource(
          currentUser,
          (String) originalIdentity.get("actor"),
          (String) originalIdentity.get("extSourceName"),
          (String) originalIdentity.get("extSourceType"),
          (Integer) originalIdentity.get("extSourceLoa"));
    }

    // merge current identity into original user
    if (currentUser == null) {
      createExtSourceAndUserExtSource(
          originalUser,
          sess.getPerunPrincipal().getActor(),
          sess.getPerunPrincipal().getExtSourceName(),
          sess.getPerunPrincipal().getExtSourceType(),
          sess.getPerunPrincipal().getExtSourceLoa());
    }

    AuthzResolverBlImpl.refreshSession(sess);

    requestCache.remove(token);

    return perun.getUsersManager().getUserExtSources(sess, sess.getPerunPrincipal().getUser());
  }
 @Override
 public void payoffUpdated(UserPayoffEvent uPE) {
   if (userInfo.equals(uPE.getUser())) {
     this.repaint();
   }
 }