if (query == null) { query = ""; }
    protected void doDSGet(Context context,        HttpServletRequest request,        HttpServletResponse response)        throws ServletException, IOException, SQLException, AuthorizeException    {        // Get the query        String query = request.getParameter("query");        // Get the location parameter, if any        String location = request.getParameter("location");        String newURL;        // If there is a location parameter, we should redirect to        // do the search with the correct location.        if (location != null && !location.equals(""))        {            String url = "";            if (!location.equals("/"))            {                // Location is a Handle                url = "/handle/" + location;            }                        // Encode the query            query = URLEncoder.encode(query);                        // Do the redirect            response.sendRedirect(response.encodeRedirectURL(                    request.getContextPath() + url +                    "/simple-search?query=" + query));            return;        }        // Build log information        String logInfo = "";        // Get our location        Community community   = UIUtil.getCommunityLocation(request);        Collection collection = UIUtil.getCollectionLocation(request);        // handles for the search results or the results        List itemHandles       = null;        List communityHandles  = null;        List collectionHandles = null;        // 'de-handled' search results        Item[]       resultsItems;        Community[]  resultsCommunities;        Collection[] resultsCollections;                // Perform the search        try        {            if (collection != null)            {                logInfo = "collection_id=" + collection.getID() + ",";                // Values for drop-down box                request.setAttribute("community", community);                request.setAttribute("collection", collection);                // we're in a collection, only display item results                itemHandles = DSQuery.getItemResults(DSQuery.doQuery(query, collection));                collectionHandles = new ArrayList();                communityHandles = new ArrayList();            }            else if (community != null)            {                logInfo = "community_id=" + community.getID() + ",";                request.setAttribute("community", community);                // Get the collections within the community for the dropdown box                request.setAttribute("collection.array",                    community.getCollections());                HashMap results = DSQuery.doQuery(query, community);                                // we're in a community, display item and collection results                itemHandles       = DSQuery.getItemResults(results);                collectionHandles = DSQuery.getCollectionResults(results);                communityHandles = new ArrayList();            }            else            {                // Get all communities for dropdown box                Community[] communities = Community.findAll(context);                request.setAttribute("community.array", communities);                HashMap results = DSQuery.doQuery(query);                                // searching everything, return all results                itemHandles      = DSQuery.getItemResults(results);                communityHandles = DSQuery.getCommunityResults(results);                collectionHandles= DSQuery.getCollectionResults(results);            }            // limit search results to 50 or fewer items - no limit on            // number of communities and collections            int numItems = (itemHandles.size() > 50 ? 50 : itemHandles.size() );            // Make objects from the handles - make arrays, fill them out            resultsItems       = new Item      [numItems                ];            resultsCommunities = new Community [communityHandles.size() ];            resultsCollections = new Collection[collectionHandles.size()];                        for (int i = 0; i < numItems; i++)            {                String myhandle = (String) itemHandles.get(i);                                Object o = HandleManager.resolveToObject(context, myhandle);                                resultsItems[i] = (Item)o;                if (resultsItems[i] == null)                {                    throw new SQLException("Query \"" + query +                        "\" returned unresolvable handle: " + myhandle);                }            }            for (int i = 0; i < collectionHandles.size(); i++)            {                String myhandle = (String) collectionHandles.get(i);                                Object o = HandleManager.resolveToObject(context, myhandle);                                resultsCollections[i] = (Collection)o;                if (resultsCollections[i] == null)                {                    throw new SQLException("Query \"" + query +                        "\" returned unresolvable handle: " + myhandle);                }            }            for (int i = 0; i < communityHandles.size(); i++)            {                String myhandle = (String) communityHandles.get(i);                                Object o = HandleManager.resolveToObject(context, myhandle);                                resultsCommunities[i] = (Community)o;                if (resultsCommunities[i] == null)                {                    throw new SQLException("Query \"" + query +                        "\" returned unresolvable handle: " + myhandle);                }            }            // Log            log.info(LogManager.getHeader(context,                "search",                logInfo + "query=\"" + query + "\",results=(" + resultsCommunities.length + "," + resultsCollections.length + "," + resultsItems.length + ")"));        }        catch (ParseException pe)        {            /*             * A parse exception means there were some weird characters in             * the query we couldn't resolve.  We'll pretend the search went             * OK but with no results for the user, but log the error, since             * this shouldn't really happen.             */            log.warn(LogManager.getHeader(context,                "search_exception",                logInfo + "query=\"" + query + "\""),                pe);            // Empty results            resultsItems       = new Item[0];            resultsCommunities = new Community[0];            resultsCollections = new Collection[0];        }    	catch (TokenMgrError tme)	{            // Similar to parse exception            log.warn(LogManager.getHeader(context,                "search_exception",                logInfo + "query=\"" + query + "\""),                tme);            // Empty results            resultsItems       = new Item[0];            resultsCommunities = new Community[0];            resultsCollections = new Collection[0];	}        // Pass the results to the display JSP        request.setAttribute("items",       resultsItems      );        request.setAttribute("communities", resultsCommunities);        request.setAttribute("collections", resultsCollections);        // And the original query string        request.setAttribute("query", query);        JSPManager.showJSP(request, response, "/search/results.jsp");    }