code: private void changeAvailability(
          CmsResource resource,
          Date released,
          boolean resetReleased,
          Date expired,
          boolean resetExpired,
          boolean modifySubresources)
      throws CmsException {
  
          CmsObject cms = m_dialogContext.getCms();
          CmsLockActionRecord lockActionRecord = CmsLockUtil.ensureLock(cms, resource);
          try {
              long newDateReleased;
              if (resetReleased || (released != null)) {
                  newDateReleased = released != null ? released.getTime() : CmsResource.DATE_RELEASED_DEFAULT;
                  cms.setDateReleased(resource, newDateReleased, modifySubresources);
              }
              long newDateExpired;
              if (resetExpired || (expired != null)) {
                  newDateExpired = expired != null ? expired.getTime() : CmsResource.DATE_EXPIRED_DEFAULT;
                  cms.setDateExpired(resource, newDateExpired, modifySubresources);
              }
          } finally {
              if (lockActionRecord.getChange() == LockChange.locked) {
                  try {
                      cms.unlockResource(resource);
                  } catch (CmsLockException e) {
                      LOG.warn(e.getLocalizedMessage(), e);
                  }
              }
  
          }
      }
docs: Changes availability.<p>
  
  @param resource the resource
  @param released release date
  @param resetReleased reset release date
  @param expired expiration date
  @param resetExpired reset expiration date
  @param modifySubresources modify children
  
  @throws CmsException if something goes wrong