Uploaded image for project: 'Grouper'
  1. Grouper
  2. GRP-373

find by subject id or identifier has bad logic

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 1.5.1
    • 1.5.0
    • API
    • None

    Description

      I changed it to this, does it look better? We should write a test case for it at some point.
      I didn't merge yet, but will at some point. Do you need it sooner than later?

      We should probably post 1.5.2 at some point not too long...

      Thanks,
      chris

      public Subject getSubjectByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull)
      throws SubjectNotFoundException, SubjectNotUniqueException {
      Subject subject = null;

      //try by id first
      subject = this.getSubject(idOrIdentifier, false);

      //try by identifier if not by id
      if (subject == null)

      { subject = this.getSubjectByIdentifier(idOrIdentifier, false); }

      //if null at this point, and exception, then throw it
      if (subject == null && exceptionIfNull)

      { throw new SubjectNotFoundException("Cant find subject by id or identifier: '" + idOrIdentifier + "'"); }

      return subject;
      }

      ----Original Message----
      Sent: Monday, January 11, 2010 4:03 PM
      To: Chris Hyzer
      Cc: Shilen Patel; Gary Brown
      Subject: Re: BaseSourceAdapter getSubjectByIdOrIdentifier() ?

      Oh, and, I guess that method doesn't really work if exceptionIfNull is
      false, since if getSubject() doesn't return null and
      getSubjectByIdentifier does, the result will be null.

      > Sure, please commit, since I don't know how to merge 1.5 to 1.6 -
      > maybe you could clue me in ?
      >
      > On Mon, Jan 11, 2010 at 2:58 PM, Chris Hyzer <mchyzer@isc.upenn.edu> wrote:
      >> Yes, it should, whoops... that should go in the 1.5 branch... let me know if you want me to commit it.
      >>
      >> Good catch!
      >> Thanks,
      >> Chris
      >>
      >>
      >> ----Original Message----
      >> Sent: Monday, January 11, 2010 3:52 PM
      >> To: Chris Hyzer
      >> Cc: Shilen Patel; Gary Brown
      >> Subject: BaseSourceAdapter getSubjectByIdOrIdentifier() ?
      >>
      >> Hey,
      >>
      >> Shouldn't SubjectNotFoundException be caught when calling
      >> this.getSubjectByIdentifier() ? is SubjectNotUniqueException a typo ?
      >>
      >> public Subject getSubjectByIdOrIdentifier(String idOrIdentifier,
      >> boolean exceptionIfNull)
      >> throws SubjectNotFoundException, SubjectNotUniqueException {
      >> Subject subject = null;
      >> try

      { >> subject = this.getSubject(idOrIdentifier, exceptionIfNull); >> }

      catch (SubjectNotFoundException snfe) {
      >> try

      { >> subject = this.getSubjectByIdentifier(idOrIdentifier, exceptionIfNull); >> }

      catch (SubjectNotUniqueException snfe2) {
      >> if (exceptionIfNull)

      { >> throw snfe2; >> }

      >> return null;
      >> }
      >> }
      >> return subject;
      >> }
      >>
      >

      Attachments

        Activity

          People

            chris.hyzer@at.internet2.edu Chris Hyzer (upenn.edu)
            chris.hyzer@at.internet2.edu Chris Hyzer (upenn.edu)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: