public void updateAsset(
      long userId, TasksEntry tasksEntry, long[] assetCategoryIds, String[] assetTagNames)
      throws PortalException, SystemException {

    AssetEntryLocalServiceUtil.updateEntry(
        userId,
        tasksEntry.getGroupId(),
        TasksEntry.class.getName(),
        tasksEntry.getTasksEntryId(),
        assetCategoryIds,
        assetTagNames);
  }
  public static boolean contains(
      PermissionChecker permissionChecker, TasksEntry tasksEntry, String actionId) {

    if (permissionChecker.getUserId() == tasksEntry.getAssigneeUserId()) {
      return true;
    }

    if (permissionChecker.hasOwnerPermission(
        tasksEntry.getCompanyId(),
        TasksEntry.class.getName(),
        tasksEntry.getTasksEntryId(),
        tasksEntry.getUserId(),
        actionId)) {

      return true;
    }

    return permissionChecker.hasPermission(
        tasksEntry.getGroupId(),
        TasksEntry.class.getName(),
        tasksEntry.getTasksEntryId(),
        actionId);
  }
  public TasksEntry updateTasksEntry(
      long tasksEntryId,
      String title,
      int priority,
      long assigneeUserId,
      long resolverUserId,
      int dueDateMonth,
      int dueDateDay,
      int dueDateYear,
      int dueDateHour,
      int dueDateMinute,
      boolean neverDue,
      int status,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Tasks entry

    Date now = new Date();

    TasksEntry tasksEntry = tasksEntryPersistence.findByPrimaryKey(tasksEntryId);

    User user = UserLocalServiceUtil.getUserById(tasksEntry.getUserId());

    Date dueDate = null;

    if (!neverDue) {
      dueDate =
          PortalUtil.getDate(
              dueDateMonth,
              dueDateDay,
              dueDateYear,
              dueDateHour,
              dueDateMinute,
              user.getTimeZone(),
              new TasksEntryDueDateException());
    }

    tasksEntry.setModifiedDate(now);
    tasksEntry.setTitle(title);
    tasksEntry.setPriority(priority);
    tasksEntry.setAssigneeUserId(assigneeUserId);
    tasksEntry.setDueDate(dueDate);

    if (status == TasksEntryConstants.STATUS_RESOLVED) {
      tasksEntry.setResolverUserId(resolverUserId);
      tasksEntry.setFinishDate(now);
    } else {
      tasksEntry.setResolverUserId(0);
      tasksEntry.setFinishDate(null);
    }

    tasksEntry.setStatus(status);

    tasksEntryPersistence.update(tasksEntry, false);

    // Asset

    updateAsset(
        tasksEntry.getUserId(),
        tasksEntry,
        serviceContext.getAssetCategoryIds(),
        serviceContext.getAssetTagNames());

    // Social

    int activity = TasksActivityKeys.UPDATE_ENTRY;

    if (status == TasksEntryConstants.STATUS_RESOLVED) {
      activity = TasksActivityKeys.RESOLVE_ENTRY;
    } else if (status == TasksEntryConstants.STATUS_REOPENED) {
      activity = TasksActivityKeys.REOPEN_ENTRY;
    }

    SocialActivityLocalServiceUtil.addActivity(
        serviceContext.getUserId(),
        tasksEntry.getGroupId(),
        TasksEntry.class.getName(),
        tasksEntryId,
        activity,
        StringPool.BLANK,
        assigneeUserId);

    return tasksEntry;
  }