public void removeImageAttachToRank(final Rank rank, final RankImage imageAttach) {
    LOG.info("removeImageAttachToRank(final Rank rank, final RankImage imageAttach)");
    if (rank == null || imageAttach == null) {
      throw new IllegalArgumentException("Null Argument");
    }

    if (!isRanksEnabled()) {
      LOG.warn("removeImageAttachToRank invoked, but ranks are disabled");
      return;
    }

    HibernateCallback hcb =
        session -> {
          Rank returnedData = (Rank) session.get(RankImpl.class, rank.getId());
          RankImage returnedAttach =
              (RankImage) session.get(RankImageImpl.class, Long.valueOf(imageAttach.getId()));
          if (returnedData != null) {
            returnedData.setRankImage(null);
            session.saveOrUpdate(returnedData);

            if (returnedAttach.getAttachmentId().toLowerCase().startsWith("/attachment"))
              try {
                contentHostingService.removeResource(returnedAttach.getAttachmentId());
                session.delete(returnedAttach);
              } catch (PermissionException | IdUnusedException | TypeException | InUseException e) {
                e.printStackTrace();
              }
          }
          return null;
        };
    getHibernateTemplate().execute(hcb);
  }
  public static void removeResource(org.sakaiproject.content.api.ContentResourceEdit param0)
      throws org.sakaiproject.exception.PermissionException {
    org.sakaiproject.content.api.ContentHostingService service = getInstance();
    if (service == null) return;

    service.removeResource(param0);
  }
  public static void removeResource(java.lang.String param0)
      throws org.sakaiproject.exception.PermissionException,
          org.sakaiproject.exception.IdUnusedException, org.sakaiproject.exception.TypeException,
          org.sakaiproject.exception.InUseException {
    org.sakaiproject.content.api.ContentHostingService service = getInstance();
    if (service == null) return;

    service.removeResource(param0);
  }