// get the community or collection location for the browse request
// Note that we are only interested in getting the "smallest" container,
// so if we find a collection, we don't bother looking up the community
Collection collection = null;
Community community = null;
collection = UIUtil.getCollectionLocation(request);
if (collection == null)
{
community = UIUtil.getCommunityLocation(request);
}
// process the input, performing some inline validation
BrowseIndex bi = null;
if (type != null && !"".equals(type))
{
bi = BrowseIndex.getBrowseIndex(type);
}
if (bi == null)
{
if (sortBy > 0)
bi = BrowseIndex.getBrowseIndex(SortOption.getSortOption(sortBy));
else
bi = BrowseIndex.getBrowseIndex(SortOption.getDefaultSortOption());
}
// If we don't have a sort column
if (bi != null && sortBy == -1)
{
// Get the default one
SortOption so = bi.getSortOption();
if (so != null)
{
sortBy = so.getNumber();
}
}
else if (bi != null && bi.isItemIndex() && !bi.isInternalIndex())
{
// If a default sort option is specified by the index, but it isn't
// the same as sort option requested, attempt to find an index that
// is configured to use that sort by default
// This is so that we can then highlight the correct option in the navigation
SortOption bso = bi.getSortOption();
SortOption so = SortOption.getSortOption(sortBy);
if ( bso != null && bso != so)
{
BrowseIndex newBi = BrowseIndex.getBrowseIndex(so);
if (newBi != null)
{
bi = newBi;
type = bi.getName();
}
}
}
if (order == null && bi != null)
{
order = bi.getDefaultOrder();
}
// If the offset is invalid, reset to 0
if (offset < 0)
{
offset = 0;
}
// if no resultsperpage set, default to 20
if (resultsperpage < 0)
{
resultsperpage = 20;
}
// if year and perhaps month have been selected, we translate these into "startsWith"
// if startsWith has already been defined then it is overwritten
if (year != null && !"".equals(year) && !"-1".equals(year))
{
startsWith = year;
if ((month != null) && !"-1".equals(month) && !"".equals(month))
{
// subtract 1 from the month, so the match works appropriately
if ("ASC".equals(order))
{
month = Integer.toString((Integer.parseInt(month) - 1));
}
// They've selected a month as well
if (month.length() == 1)
{
// Ensure double-digit month number
month = "0" + month;
}
startsWith = year + "-" + month;
if ("ASC".equals(order))
{
startsWith = startsWith + "-32";
}
}
}
// determine which level of the browse we are at: 0 for top, 1 for second
int level = 0;
if (value != null || authority != null)
{
level = 1;
}
// if sortBy is still not set, set it to 0, which is default to use the primary index value
if (sortBy == -1)
{
sortBy = 0;
}
// figure out the setting for author list truncation
if (etAl == -1) // there is no limit, or the UI says to use the default
{
int limitLine = ConfigurationManager.getIntProperty("webui.browse.author-limit");
if (limitLine != 0)
{
etAl = limitLine;
}
}
else // if the user has set a limit
{
if (etAl == 0) // 0 is the user setting for unlimited
{
etAl = -1; // but -1 is the application setting for unlimited
}
}
// log the request
String comHandle = "n/a";
if (community != null)
{
comHandle = community.getHandle();
}
String colHandle = "n/a";
if (collection != null)
{
colHandle = collection.getHandle();