Exemplo n.º 1
0
  Object onDelete(String courseUuid) {
    if (!StudentUtil.isPossibleUuid(courseUuid)) {
      LOG.info("Invalid CourseUUID");
      courseUuid = null;
      course = null;
      return this;
    }

    this.courseUuid = courseUuid;
    int courseVersion = 0;

    try {
      courseManagerService.deleteCourse(courseUuid, courseVersion);
    } catch (ObjectNotFoundException e) {
      // object has already been deleted.
      LOG.trace("course not found: " + courseUuid);
    } catch (RestClientFailureException e) {
      createForm.recordError("Internal error on server.");
      createForm.recordError(e.getMessage());

      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      deleteMessage = ExceptionUtil.getRootCauseMessage(e);

      // Trigger new event "failedDelete" which will bubble up.
      componentResources.triggerEvent(FAILED_DELETE, new Object[] {courseUuid}, null);
      // We don't want "delete" to bubble up, so we return true to say
      // we've handled it.
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
      return true;
    } catch (Exception e) {
      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      deleteMessage = ExceptionUtil.getRootCauseMessage(e);

      // Trigger new event "failedDelete" which will bubble up.
      componentResources.triggerEvent(FAILED_DELETE, new Object[] {courseUuid}, null);
      // We don't want "delete" to bubble up, so we return true to say
      // we've handled it.
      // TODO: replace with exception service
      LOG.info("unhandled exception during deletion", e);
      return true;
    }

    // Trigger new event "successfulDelete" which will bubble up.
    componentResources.triggerEvent(SUCCESFUL_DELETE, new Object[] {courseUuid}, null);
    // We don't want "delete" to bubble up, so we return true to say we've
    // handled it.
    return indexPage;
  }
Exemplo n.º 2
0
  void onValidateFromCreateForm() {

    if (createForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      course =
          courseManagerService.createCourse(
              course.getCode(), course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      createForm.recordError("Internal error on server.");
      createForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      createForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }
Exemplo n.º 3
0
  void onValidateFromUpdateForm() {

    if (updateForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      courseManagerService.updateCourse(
          course, course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      updateForm.recordError("Internal error on server.");
      updateForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      updateForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }
Exemplo n.º 4
0
 void onPrepareForSubmitFromUpdateForm() {
   // Get objects for the form fields to overlay.
   if (!StudentUtil.isPossibleUuid(courseUuid)) {
     LOG.info("Invalid CourseUUID");
     courseUuid = null;
     course = new Course();
   } else {
     try {
       course = courseFinderService.findCourseByUuid(courseUuid);
     } catch (ObjectNotFoundException e) {
       course = new Course();
       updateForm.recordError("Course has been deleted by another process.");
       LOG.trace("course not found: " + courseUuid);
     }
   }
 }