protected void validate(long courseTypeId, String typeName)
      throws PortalException, SystemException {
    if (Validator.isNull(typeName)) {
      throw new CourseTypeException();
    }

    CourseType courseType = CourseTypeLocalServiceUtil.fetchCourseTypeByTypeName(typeName);
    if (Validator.isNotNull(courseType)) {
      if (!Validator.equals(courseType.getCourseTypeId(), courseTypeId)) {
        throw new DuplicateCourseTypeException();
      }
    }
  }
  public CourseType deleteCourseType(long courseTypeId, ServiceContext serviceContext)
      throws PortalException, SystemException {
    CourseType courseType = CourseTypeLocalServiceUtil.getCourseType(courseTypeId);

    List<Course> coursesToDelete = CourseLocalServiceUtil.getCoursesByCourseTypeId(courseTypeId);
    for (Course course : coursesToDelete) {
      CourseLocalServiceUtil.deleteCourse(course.getCourseId(), serviceContext);
    }

    resourceLocalService.deleteResource(
        courseType.getCompanyId(),
        courseType.getClass().getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        courseTypeId);

    return deleteCourseType(courseType);
  }