public ViewEnum getView(StringBuilder uri)
throws IOException, ServletException
{
ViewEnum view = null;
// start at the beginning of the uri and look for the index of '/%d/'
int tabIndex = uri.indexOf("/"+ViewEnum.FAMILY_VIEW.view()+"/");
if(tabIndex == -1)
{
tabIndex = uri.indexOf("/"+ViewEnum.PEDIGREE_VIEW.view()+"/");
}
else if(view == null)
{
view = ViewEnum.FAMILY_VIEW;
}
if(tabIndex == -1)
{
tabIndex = uri.indexOf("/"+ViewEnum.INDIVIDUAL_VIEW.view()+"/");
}
else if(view == null)
{
view = ViewEnum.PEDIGREE_VIEW;
}
if(tabIndex == -1)
{
tabIndex = uri.indexOf("/"+ViewEnum.GEDCOM_SEARCH_VIEW.view()+"/");
}
else if(view == null)
{
view = ViewEnum.INDIVIDUAL_VIEW;
}
if(tabIndex == -1)
{
tabIndex = uri.indexOf("/"+ViewEnum.SUBMITTER_VIEW.view()+"/");
}
else if(view == null)
{
view = ViewEnum.GEDCOM_SEARCH_VIEW;
}
if(tabIndex == -1)
{
tabIndex = uri.indexOf("/"+ViewEnum.ALL_GLINKS_VIEW.view()+"/");
}
else if(view == null)
{
view = ViewEnum.SUBMITTER_VIEW;
}
if(tabIndex == -1)
{
// If an invalid view does occur then it is not the fault of the end
// user so just throw an exception into the console log but don't tell the end
// user about it.
new Exception("Invalid view in uri: "+uri).printStackTrace();
view = null;
}
else if(view == null)
{
view = ViewEnum.ALL_GLINKS_VIEW;
}
if(view != null)
{
uri.delete(0,tabIndex+view.view().length()+2);
}
return view;
}