}
// the last part of the gedcomURL should be the individual id
// if the gedcomURL does not end in an individual id then the
// data for the first person in the gedcom is retrieved
Gedcom gedcom = gedcomURL.loadGedcom(networkReload, request);
Indi indi;
if(gedcomURL.isValidIndividualId())
{
indi = (Indi)gedcom.getEntity(Gedcom.INDI, gedcomURL.getIndividualId());
if(indi == null)
{
throw new ServletException(ErrorCodes.NONEXISTANT_INDI.getErrorMessage(new Object[] {gedcomURL.getIndividualId(), gedcomURL.getGedcomURL()}));
}
}
else
{
indi = (Indi)gedcom.getFirstEntity(Gedcom.INDI);
if(indi == null)
{
throw new ServletException(ErrorCodes.NO_INDIVIDUALS.getErrorMessage(new Object[] {gedcomURL.getGedcomURL()}));
}
gedcomURL.setIndividualId(indi.getId());
}
//switch on the view to know how to get the correct view data into X-JSON format
BaseView baseView = null;
switch(view)
{
case FAMILY_VIEW:
LOG.finest("The gedapi view is: family: "+indi);
//create family view java classes like described in vraptor2 (spouse, individual, parent, child, marriage), populate the
//top level vraptor2 FamilyView class with the correct number of instances of spouse, individual, parent, child, marriage
//objects and then use vraptor2 to serialize the FamilyView into a JSON string and send that back to the browser
baseView = Gedcom2View.familyView(indi, networkReload, gedcomURL);
break;
case PEDIGREE_VIEW:
LOG.finest("The gedapi view is: pedigree: "+indi);
baseView = Gedcom2View.pedigreeView(indi, networkReload, gedcomURL);
break;
case INDIVIDUAL_VIEW:
LOG.finest("The gedapi view is: individual list: "+indi);
baseView = Gedcom2View.individualListView(gedcom, networkReload, gedcomURL);
break;
case GEDCOM_SEARCH_VIEW:
LOG.finest("The gedapi view is: GEDCOM Search: "+indi);
baseView = Gedcom2View.gedcomSearchView(gedcom, gedcomURL, searchCriteria, searchScope);
break;
case SUBMITTER_VIEW:
SSOSubject authenticated = (SSOSubject)request.getAttribute(SSOSubject.SSOSUBJECT_KEY);
if(authenticated == null)
{
throw new ServletException("The request does not have an "+SSOSubject.SSOSUBJECT_KEY+" attribute, this is not allowed!!!");
}
LOG.finest("The gedapi view is: submitter: "+indi);
baseView = Gedcom2View.gedcomSubmitterView(gedcom, gedcomURL);
break;
case ALL_GLINKS_VIEW:
LOG.finest("The gedapi view is: ALL_GLINKS: "+indi);
baseView = Gedcom2View.gedcomAllGLinksView(gedcom, gedcomURL);
break;
default:
throw new ServletException(ErrorCodes.VIEW_NOT_SUPPORTED.getErrorMessage(new Object[] {view, gedcomURL}));
}
long gedcomLastModified = gedcom.getOrigin().getLastModified();
if(gedcomLastModified > baseView.lastModified)
{
baseView.lastModified = gedcomLastModified;
}