code: public void deleteHistoricalVersions(
          CmsRequestContext context,
          int versionsToKeep,
          int versionsDeleted,
          long timeDeleted,
          I_CmsReport report)
      throws CmsException, CmsRoleViolationException {
  
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              CmsFolder root = readFolder(dbc, "/", CmsResourceFilter.ALL);
              checkRole(dbc, CmsRole.WORKPLACE_MANAGER.forOrgUnit(null));
              checkPermissions(dbc, root, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
              m_driverManager.deleteHistoricalVersions(dbc, versionsToKeep, versionsDeleted, timeDeleted, report);
          } catch (Exception e) {
              dbc.report(
                  null,
                  Messages.get().container(
                      Messages.ERR_DELETE_HISTORY_4,
                      new Object[] {
                          "/",
                          new Integer(versionsToKeep),
                          new Integer(versionsDeleted),
                          new Date(timeDeleted)}),
                  e);
          } finally {
              dbc.clear();
          }
      }
docs: Deletes the versions from the history tables, keeping the given number of versions per resource.<p>
  
  @param context the current request context
  @param versionsToKeep number of versions to keep, is ignored if negative
  @param versionsDeleted number of versions to keep for deleted resources, is ignored if negative
  @param timeDeleted deleted resources older than this will also be deleted, is ignored if negative
  @param report the report for output logging
  
  @throws CmsException if operation was not successful
  @throws CmsRoleViolationException if the current user does not own the role {@link CmsRole#WORKPLACE_MANAGER}