/**
   * @param activities
   * @param context
   * @return
   */
  public String completeAll(List<ActivityInstanceOutDataDTO> activities, String context) {
    NotificationMap notificationMap = new NotificationMap();

    for (ActivityInstanceOutDataDTO aiDto : activities) {
      try {
        activityInstanceUtils.complete(aiDto.oid, context, aiDto.outData);
        notificationMap.addSuccess(
            new NotificationDTO(aiDto.oid, null, ActivityInstanceState.Completed.getName()));
      } catch (Exception e) {
        notificationMap.addFailure(new NotificationDTO(aiDto.oid, null, e.getMessage()));
      }
    }
    return GsonUtils.toJsonHTMLSafeString(notificationMap);
  }
  /**
   * @author Yogesh.Manware
   * @param request
   * @return
   */
  public String abortActivities(String request) {
    JsonObject json = GsonUtils.readJsonObject(request);
    String scope = GsonUtils.extractString(json, "scope");

    Type listType = new TypeToken<List<Long>>() {}.getType();

    @SuppressWarnings("unchecked")
    List<Long> activities =
        (List<Long>)
            GsonUtils.extractList(GsonUtils.extractJsonArray(json, "activities"), listType);
    NotificationMap notificationMap = new NotificationMap();

    if (AbortScope.SubHierarchy.toString().equalsIgnoreCase(scope)) {
      notificationMap = activityInstanceUtils.abortActivities(AbortScope.SubHierarchy, activities);
    } else if (AbortScope.RootHierarchy.toString().equalsIgnoreCase(scope)) {
      notificationMap = activityInstanceUtils.abortActivities(AbortScope.RootHierarchy, activities);
    } else {
      throw new IllegalArgumentException("Scope not valid : " + scope);
    }
    return GsonUtils.toJsonHTMLSafeString(notificationMap);
  }