Esempio n. 1
0
 /**
  * After deleting the Manual Shares, we are also deleting the sharing entity data of the deleted
  * Manual Shares
  */
 @Override
 public void onAfterDelete(List<ManualShare> manualShares, List<ManualShare> old)
     throws TriggerException {
   // Delete SharingEntries for all ManualShares
   InvocationContext iContext = InvocationContext.get();
   for (ManualShare share : manualShares) {
     // Delete SharingEntry of share
     Instance record = share.getRecord();
     SharingEntityData.delete(
         iContext.getDatabase(), SharingEntityData.TYPE_MANUAL, share, record);
   }
 }
Esempio n. 2
0
  /**
   * Preparing SHARING_ENTITY_DATA for given manual share, and inserting thos object in Db
   *
   * @param manualShares
   */
  private void insertSharingEntry(ManualShare manualShare) {
    Instance entity = manualShare.getRecord();
    SharedTo sharedTo = manualShare.getSharedTo();
    Instance reason = manualShare.getRowCause();

    SharingEntityData sEntry = new SharingEntityData(entity);
    if (reason != null) {
      // Reason will be provided when a manual share created by apex code
      sEntry.setSharingType(SharingEntityData.TYPE_APEX);
    } else {
      // User's manual share in UI
      sEntry.setSharingType(SharingEntityData.TYPE_MANUAL);
    }
    sEntry.setManualShare(manualShare.getId());
    sEntry.setIncludingSub(sharedTo.getIncludingSub());
    sEntry.setUserOrGroup(manualShare.getUserOrGroupId().getId());
    sEntry.setAccessLevel(manualShare.getAccessLevel());

    // inserting the prepared Sharing Entity Data into DB
    InvocationContext iContext = InvocationContext.get();
    sEntry.insert(iContext.getDatabase());
  }