Example usage for org.apache.commons.lang StringUtils startsWithIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils startsWithIgnoreCase.

Prototype

public static boolean startsWithIgnoreCase(String str, String prefix) 

Source Link

Document

Case insensitive check if a String starts with a specified prefix.

Usage

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Parses the message text passed in and returns the resulting rich message component structure.
 *
 * <p>If special characters [] are detected the message is split at that location.  The types of features supported
 * by the parse are (note that &lt;&gt; are not part of the content, they specify placeholders):
 * <ul>//w  ww.  j  a v  a  2s  .co  m
 * <li>[id=&lt;component id&gt;] - insert component with id specified at that location in the message</li>
 * <li>[n] - insert component at index n from the inlineComponent list</li>
 * <li>[&lt;html tag&gt;][/&lt;html tag&gt;] - insert html content directly into the message content at that
 * location,
 * without the need to escape the &lt;&gt; characters in xml</li>
 * <li>[color=&lt;html color code/name&gt;][/color] - wrap content in color tags to make text that color
 * in the message</li>
 * <li>[css=&lt;css classes&gt;][/css] - apply css classes specified to the wrapped content - same as wrapping
 * the content in span with class property set</li>
 * <li>[link=&lt;href src&gt;][/link] - an easier way to create an anchor that will open in a new page to the
 * href specified after =</li>
 * <li>[action=&lt;href src&gt;][/action] - create an action link inline without having to specify a component by
 * id or index.  The options for this are as follows and MUST be in a comma seperated list in the order specified
 * (specify 1-4 always in this order):
 * <ul>
 * <li>methodToCall(String)</li>
 * <li>validateClientSide(boolean) - true if not set</li>
 * <li>ajaxSubmit(boolean) - true if not set</li>
 * <li>successCallback(js function or function declaration) - this only works when ajaxSubmit is true</li>
 * </ul>
 * The tag would look something like this [action=methodToCall]Action[/action] in most common cases.  And in more
 * complex cases [action=methodToCall,true,true,functionName]Action[/action].  <p>In addition to these settings,
 * you can also specify data to send to the server in this fashion (space is required between settings and data):
 * </p>
 * [action=&lt;action settings&gt; data={key1: 'value 1', key2: value2}]
 * </li>
 * </ul>
 * If the [] characters are needed in message text, they need to be declared with an escape character: \\[ \\]
 * </p>
 *
 * @param messageId id of the message
 * @param messageText message text to be parsed
 * @param componentList the inlineComponent list
 * @param view the current view
 * @param parseComponents true to parse components
 * @return list of components representing the parsed message structure
 */
public static List<Component> parseMessage(String messageId, String messageText, List<Component> componentList,
        View view, boolean parseComponents) {
    messageText = messageText.replace("\\" + KRADConstants.MessageParsing.LEFT_TOKEN,
            KRADConstants.MessageParsing.LEFT_BRACKET);
    messageText = messageText.replace("\\" + KRADConstants.MessageParsing.RIGHT_TOKEN,
            KRADConstants.MessageParsing.RIGHT_BRACKET);
    messageText = messageText.replace(KRADConstants.MessageParsing.RIGHT_TOKEN,
            KRADConstants.MessageParsing.RIGHT_TOKEN_PLACEHOLDER);
    String[] messagePieces = messageText.split("[\\" + KRADConstants.MessageParsing.LEFT_TOKEN + "|\\"
            + KRADConstants.MessageParsing.RIGHT_TOKEN + "]");

    List<Component> messageComponentStructure = new ArrayList<Component>();

    //current message object to concatenate to after it is generated to prevent whitespace issues and
    //creation of multiple unneeded objects
    Message currentMessageComponent = null;

    for (String messagePiece : messagePieces) {
        if (messagePiece.endsWith(KRADConstants.MessageParsing.RIGHT_TOKEN_MARKER)) {
            messagePiece = StringUtils.removeEnd(messagePiece, KRADConstants.MessageParsing.RIGHT_TOKEN_MARKER);

            if (StringUtils.startsWithIgnoreCase(messagePiece,
                    KRADConstants.MessageParsing.COMPONENT_BY_ID + "=") && parseComponents) {
                //Component by Id
                currentMessageComponent = processIdComponentContent(messagePiece, messageComponentStructure,
                        currentMessageComponent, view);
            } else if (messagePiece.matches("^[0-9]+( .+=.+)*$") && parseComponents) {
                //Component by index of inlineComponents
                currentMessageComponent = processIndexComponentContent(messagePiece, componentList,
                        messageComponentStructure, currentMessageComponent, view, messageId);
            } else if (StringUtils.startsWithIgnoreCase(messagePiece, KRADConstants.MessageParsing.COLOR + "=")
                    || StringUtils.startsWithIgnoreCase(messagePiece,
                            "/" + KRADConstants.MessageParsing.COLOR)) {
                //Color span
                currentMessageComponent = processColorContent(messagePiece, currentMessageComponent, view);
            } else if (StringUtils.startsWithIgnoreCase(messagePiece,
                    KRADConstants.MessageParsing.CSS_CLASSES + "=")
                    || StringUtils.startsWithIgnoreCase(messagePiece,
                            "/" + KRADConstants.MessageParsing.CSS_CLASSES)) {
                //css class span
                currentMessageComponent = processCssClassContent(messagePiece, currentMessageComponent, view);
            } else if (StringUtils.startsWithIgnoreCase(messagePiece, KRADConstants.MessageParsing.LINK + "=")
                    || StringUtils.startsWithIgnoreCase(messagePiece,
                            "/" + KRADConstants.MessageParsing.LINK)) {
                //link (a tag)
                currentMessageComponent = processLinkContent(messagePiece, currentMessageComponent, view);
            } else if (StringUtils.startsWithIgnoreCase(messagePiece,
                    KRADConstants.MessageParsing.ACTION_LINK + "=")
                    || StringUtils.startsWithIgnoreCase(messagePiece,
                            "/" + KRADConstants.MessageParsing.ACTION_LINK)) {
                //action link (a tag)
                currentMessageComponent = processActionLinkContent(messagePiece, currentMessageComponent, view);
            } else if (messagePiece.equals("")) {
                //do nothing    
            } else {
                //raw html content
                currentMessageComponent = processHtmlContent(messagePiece, currentMessageComponent, view);
            }
        } else {
            //raw string
            messagePiece = addBlanks(messagePiece);
            currentMessageComponent = concatenateStringMessageContent(currentMessageComponent, messagePiece,
                    view);
        }
    }

    if (currentMessageComponent != null && StringUtils.isNotEmpty(currentMessageComponent.getMessageText())) {
        messageComponentStructure.add(currentMessageComponent);
        currentMessageComponent = null;
    }

    return messageComponentStructure;
}

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Inserts &amp;nbsp; into the string passed in, if spaces exist at the beginning and/or end,
 * so spacing is not lost in html translation.
 *
 * @param text string to insert  &amp;nbsp;
 * @return String with  &amp;nbsp; inserted, if applicable
 *///from   ww w .j  a  va 2s . co  m
public static String addBlanks(String text) {
    if (StringUtils.startsWithIgnoreCase(text, " ")) {
        text = "&nbsp;" + StringUtils.removeStart(text, " ");
    }

    if (text.endsWith(" ")) {
        text = StringUtils.removeEnd(text, " ") + "&nbsp;";
    }

    return text;
}

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Process a piece of the message that has color content by creating a span with that color style set
 *
 * @param messagePiece String piece with color content
 * @param currentMessageComponent the state of the current text based message being built
 * @param view current View/*from  ww  w . ja  va2s  . co  m*/
 * @return currentMessageComponent with the new textual content generated by this method appended to its
 *         messageText
 */
private static Message processColorContent(String messagePiece, Message currentMessageComponent, View view) {
    if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) {
        messagePiece = StringUtils.remove(messagePiece, "'");
        messagePiece = StringUtils.remove(messagePiece, "\"");
        messagePiece = "<span style='color: "
                + StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.COLOR + "=") + ";'>";
    } else {
        messagePiece = "</span>";
    }

    return concatenateStringMessageContent(currentMessageComponent, messagePiece, view);
}

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Process a piece of the message that has css content by creating a span with those css classes set
 *
 * @param messagePiece String piece with css class content
 * @param currentMessageComponent the state of the current text based message being built
 * @param view current View/*from www  .  j  a v  a2s  .  co m*/
 * @return currentMessageComponent with the new textual content generated by this method appended to its
 *         messageText
 */
private static Message processCssClassContent(String messagePiece, Message currentMessageComponent, View view) {
    if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) {
        messagePiece = StringUtils.remove(messagePiece, "'");
        messagePiece = StringUtils.remove(messagePiece, "\"");
        messagePiece = "<span class='"
                + StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.CSS_CLASSES + "=") + "'>";
    } else {
        messagePiece = "</span>";
    }

    return concatenateStringMessageContent(currentMessageComponent, messagePiece, view);
}

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Process a piece of the message that has link content by creating an anchor (a tag) with the href set
 *
 * @param messagePiece String piece with link content
 * @param currentMessageComponent the state of the current text based message being built
 * @param view current View/*from www  . j a  v a  2s  . com*/
 * @return currentMessageComponent with the new textual content generated by this method appended to its
 *         messageText
 */
private static Message processLinkContent(String messagePiece, Message currentMessageComponent, View view) {
    if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) {
        //clean up href
        messagePiece = StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.LINK + "=");
        messagePiece = StringUtils.removeStart(messagePiece, "'");
        messagePiece = StringUtils.removeEnd(messagePiece, "'");
        messagePiece = StringUtils.removeStart(messagePiece, "\"");
        messagePiece = StringUtils.removeEnd(messagePiece, "\"");

        messagePiece = "<a href='" + messagePiece + "' target='_blank'>";
    } else {
        messagePiece = "</a>";
    }

    return concatenateStringMessageContent(currentMessageComponent, messagePiece, view);
}

From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java

/**
 * Process a piece of the message that has action link content by creating an anchor (a tag) with the onClick set
 * to perform either ajaxSubmit or submit to the controller with a methodToCall
 *
 * @param messagePiece String piece with action link content
 * @param currentMessageComponent the state of the current text based message being built
 * @param view current View// w  ww . j  a  v a 2s  . c  o m
 * @return currentMessageComponent with the new textual content generated by this method appended to its
 *         messageText
 */
private static Message processActionLinkContent(String messagePiece, Message currentMessageComponent,
        View view) {
    if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) {
        messagePiece = StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.ACTION_LINK + "=");
        String[] splitData = messagePiece.split(KRADConstants.MessageParsing.ACTION_DATA + "=");

        String[] params = splitData[0].trim().split("([,]+(?=([^']*'[^']*')*[^']*$))");
        String methodToCall = ((params.length >= 1) ? params[0] : "");
        String validate = ((params.length >= 2) ? params[1] : "true");
        String ajaxSubmit = ((params.length >= 3) ? params[2] : "true");
        String successCallback = ((params.length >= 4) ? params[3] : "null");

        String submitData = "null";

        if (splitData.length > 1) {
            submitData = splitData[1].trim();
        }

        methodToCall = StringUtils.remove(methodToCall, "'");
        methodToCall = StringUtils.remove(methodToCall, "\"");

        messagePiece = "<a href=\"javascript:void(null)\" onclick=\"submitForm(" + "'" + methodToCall + "',"
                + submitData + "," + validate + "," + ajaxSubmit + "," + successCallback
                + "); return false;\">";

        ViewPostMetadata viewPostMetadata = ViewLifecycle.getViewPostMetadata();
        if (viewPostMetadata != null) {
            viewPostMetadata.addAccessibleMethodToCall(methodToCall);
            viewPostMetadata.addAvailableMethodToCall(methodToCall);
        }
    } else {
        messagePiece = "</a>";
    }

    return concatenateStringMessageContent(currentMessageComponent, messagePiece, view);
}

From source file:org.ngrinder.home.service.HomeService.java

/**
 * Get panel entries containing the entries from the given RSS
 * url./*from   w  w  w.  ja  v a2s .  c o  m*/
 *
 * @param feedURL      rss url message
 * @param maxSize      max size
 * @param includeReply if including reply
 * @return {@link PanelEntry} list
 */
public List<PanelEntry> getPanelEntries(String feedURL, int maxSize, boolean includeReply) {
    SyndFeedInput input = new SyndFeedInput();
    XmlReader reader = null;
    HttpURLConnection feedConnection = null;
    try {
        List<PanelEntry> panelEntries = new ArrayList<PanelEntry>();
        URL url = new URL(feedURL);
        feedConnection = (HttpURLConnection) url.openConnection();
        feedConnection.setConnectTimeout(4000);
        feedConnection.setReadTimeout(4000);
        reader = new XmlReader(feedConnection);
        SyndFeed feed = input.build(reader);
        int count = 0;
        for (Object eachObj : feed.getEntries()) {
            SyndEntryImpl each = cast(eachObj);
            if (!includeReply && StringUtils.startsWithIgnoreCase(each.getTitle(), "Re: ")) {
                continue;
            }
            if (count++ > maxSize) {
                break;
            }
            PanelEntry entry = new PanelEntry();
            entry.setAuthor(each.getAuthor());
            entry.setLastUpdatedDate(
                    each.getUpdatedDate() == null ? each.getPublishedDate() : each.getUpdatedDate());
            entry.setTitle(each.getTitle());
            entry.setLink(each.getLink());
            panelEntries.add(entry);
        }
        Collections.sort(panelEntries);
        return panelEntries;
    } catch (Exception e) {
        LOG.error("Error while patching the feed entries for {} : {}", feedURL, e.getMessage());
    } finally {
        if (feedConnection != null) {
            feedConnection.disconnect();
        }
        IOUtils.closeQuietly(reader);
    }
    return Collections.emptyList();
}

From source file:org.onehippo.cms7.brokenlinks.BrokenLinksCheckingJob.java

private void checkBrokenLinks(final Session session, final CheckExternalBrokenLinksConfig config)
        throws RepositoryException {
    final WorkflowManager workflowManager = ((HippoWorkspace) session.getWorkspace()).getWorkflowManager();

    final LinkChecker linkChecker = new LinkChecker(config, session);
    log.info("Checking broken external links, configuration: ", config);
    // For the xpath query below, do not include a path constraint to begin with, like
    // /jcr:root/content/documents as this results in much less efficient queries
    String xpath = "//element(*,hippostd:html)";
    QueryResult result = session.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH).execute();
    NodeIterator hippostdHtmlNodes = result.getNodes();

    // the key of the links map is the uuid of the handle node
    Map<String, Set<Link>> linksByHandleUUID = new HashMap<String, Set<Link>>();
    // the unique links by URL
    Map<String, Link> linksByURL = new HashMap<String, Link>();

    long start = System.currentTimeMillis();
    int count = 0;
    int totalLinksCount = 0;
    while (hippostdHtmlNodes.hasNext()) {
        try {//from ww  w.j  av  a 2  s  .  c o m
            Node hippostdHtml = hippostdHtmlNodes.nextNode();

            if (!hippostdHtml.getPath().startsWith(config.getStartPath())) {
                // skip paths that do not start with the path we want to scan below
                continue;
            }

            // we need to group the links per handle because all hippostd:content
            // fields below a handle store their broken links directly below the handle
            Node handleNode = getHandleNode(hippostdHtml);

            if (handleNode == null) {
                // could not find handle for hippostd:html node. Skip it
                continue;
            }

            String handleUUID = handleNode.getIdentifier();
            // hippostd:content is a mandatory property so no need to check for existence
            String content = hippostdHtml.getProperty("hippostd:content").getString();

            try {
                Set<Link> linksForHandle = linksByHandleUUID.get(handleUUID);
                count++;

                final List<String> links = PlainTextLinksExtractor.getLinks(content);
                totalLinksCount += links.size();
                for (String url : links) {

                    if (isExcludedURL(config, url)) {
                        log.info("The URL is excluded while broken links checking in '{}': {}",
                                hippostdHtml.getPath(), url);
                        continue;
                    }

                    if (linksForHandle == null) {
                        linksForHandle = new HashSet<>();
                        linksByHandleUUID.put(handleUUID, linksForHandle);
                    }

                    Link alreadyPresent = linksByURL.get(url);

                    if (alreadyPresent == null) {
                        String sourceNodeIdentifier = hippostdHtml.getIdentifier();
                        Link link = new Link(url, sourceNodeIdentifier);

                        if (StringUtils.startsWithIgnoreCase(url, "http:")
                                || StringUtils.startsWithIgnoreCase(url, "https:")) {
                            linksByURL.put(url, link);
                        } else {
                            linksByURL.put(sourceNodeIdentifier + "/" + url, link);
                        }

                        log.debug("Adding to test for handle with '{}' the url '{}'", handleUUID, url);
                        linksForHandle.add(link);
                    } else {
                        log.debug("Adding to test for handle with '{}' the url '{}'", handleUUID, url);
                        linksForHandle.add(alreadyPresent);
                    }
                }
            } catch (IllegalStateException e) {
                log.warn("Unable to get link from hippostd:html for node '{}'", hippostdHtml.getPath());
            }
        } catch (RepositoryException e) {
            log.warn(
                    "RepositoryException for hippostd:html node from search result. Skip and continue with next");
        }
    }
    long scanningTook = (System.currentTimeMillis() - start);
    log.info("Finished scanning all hippostd:html nodes for external links in {} seconds.",
            String.valueOf((scanningTook / 1000.0)));
    log.info("In total {}  hippostd:html nodes were scanned.", String.valueOf(count));
    log.info("In total {} handles have links", linksByHandleUUID.size());
    log.info("In total there are {} unique links", linksByURL.size());
    log.info("In total there were {} links scanned", totalLinksCount);
    log.info("Starting scanning for external links that are broken");

    start = System.currentTimeMillis();
    // this set keeps track of scanned links to avoid needless double scanning

    // Now first check all external links whether they are available : The linkChecker runs multi-threaded thus
    // to utilize the multi-threading best, it is best to scan all Links combined, not just the ones for a single handle
    linkChecker.run(linksByURL.values());
    linkChecker.shutdown();

    log.info("Finished testing availability of all URLs. Tested '{}' URLs in {} seconds.",
            String.valueOf(linksByURL.size()), String.valueOf((scanningTook / 1000.0)));

    for (Map.Entry<String, Set<Link>> entry : linksByHandleUUID.entrySet()) {

        // all links belong to one document, so we can safely collect and process them at once:
        Collection<Link> brokenLinks = new ArrayList<Link>();
        for (Link link : entry.getValue()) {
            if (link.isBroken()) {
                brokenLinks.add(link);
            }
        }
        // the key in the Map contains the handleUUID
        try {
            Node handleNode = session.getNodeByIdentifier(entry.getKey());
            if (!brokenLinks.isEmpty() || handleNode.isNodeType(NodeType.BROKENLINKS_MIXIN)) {
                // need to get the document below the handle to be able to get the workflow
                Node doc;
                try {
                    doc = handleNode.getNode(handleNode.getName());
                } catch (PathNotFoundException e) {
                    log.warn("could not find document below handle '{}'. SKip", handleNode.getPath());
                    continue;
                }
                try {
                    Workflow reportWorkflow = workflowManager.getWorkflow("brokenlinks", new Document(doc));
                    if (reportWorkflow instanceof ReportBrokenLinksWorkflow) {
                        ((ReportBrokenLinksWorkflow) reportWorkflow).reportBrokenLinks(brokenLinks);
                    }
                } catch (WorkflowException e) {
                    if (log.isDebugEnabled()) {
                        log.warn(
                                "WorkflowException exception while trying to write link report to handle with uuid '"
                                        + entry.getKey() + "'",
                                e);
                    } else {
                        log.warn(
                                "WorkflowException exception while trying to write link report to handle with uuid '{}' : {}",
                                entry.getKey(), e.toString());
                    }
                } catch (RepositoryException e) {
                    if (log.isDebugEnabled()) {
                        log.warn("Repository exception while trying to write link report to handle with uuid '"
                                + entry.getKey() + "'", e);
                    } else {
                        log.warn(
                                "Repository exception while trying to write link report to handle with uuid '{}' : {}",
                                entry.getKey(), e.toString());
                    }
                } catch (RemoteException e) {
                    if (log.isDebugEnabled()) {
                        log.warn("Repository exception while trying to write link report to handle with uuid '"
                                + entry.getKey() + "'", e);
                    } else {
                        log.warn(
                                "Repository exception while trying to write link report to handle with uuid '{}' : {}",
                                entry.getKey(), e.toString());
                    }
                }

            }
        } catch (ItemNotFoundException e) {
            if (log.isDebugEnabled()) {
                log.warn(
                        "ItemNotFoundException exception while trying to create link report to handle with uuid '"
                                + entry.getKey() + "'",
                        e);
            } else {
                log.warn(
                        "ItemNotFoundException exception while trying to create link report to handle with uuid '{}' : {}",
                        entry.getKey(), e.toString());
            }
        } catch (RepositoryException e) {
            if (log.isDebugEnabled()) {
                log.warn(
                        "RepositoryException exception while trying to create link report to handle with uuid '"
                                + entry.getKey() + "'",
                        e);
            } else {
                log.warn(
                        "RepositoryException exception while trying to create link report to handle with uuid '{}' : {}",
                        entry.getKey(), e.toString());
            }
        }

    }

}

From source file:org.onehippo.forge.content.exim.repository.jaxrs.AbstractContentEximService.java

/**
 * Find user principal's name from {@code securityContext} or {@code request}.
 * @param securityContext security context
 * @param request servlet request//from w w w . jav a  2 s .  c  o  m
 * @return user principal's name from {@code securityContext} or {@code request}
 */
protected String getUserPrincipalName(SecurityContext securityContext, HttpServletRequest request) {
    if (securityContext != null) {
        Principal userPrincipal = securityContext.getUserPrincipal();
        if (userPrincipal != null) {
            return userPrincipal.getName();
        }
    }

    if (request != null) {
        Principal userPrincipal = request.getUserPrincipal();
        if (userPrincipal != null) {
            return userPrincipal.getName();
        }

        final String authHeader = request.getHeader("Authorization");

        if (StringUtils.isNotBlank(authHeader)) {
            if (StringUtils.startsWithIgnoreCase(authHeader, "Basic ")) {
                final String encoded = authHeader.substring(6).trim();
                final String decoded = new String(Base64.getDecoder().decode(encoded));
                return StringUtils.substringBefore(decoded, ":");
            }
        }
    }

    return null;
}

From source file:org.onehippo.forge.content.exim.repository.jaxrs.util.ResultItemSetCollector.java

/**
 * Collect nodes by executing the {@code queries} with validations and fill {@link ResultItem} instances in
 * {@code resultOut}./*from www.ja  v a2s  .c  om*/
 * @param session JCR session
 * @param queries JCR query statements for documents or binaries
 * @param binary flag whether the node paths are for binary content or not
 * @param pathsCache node path cache set, which can be useful if you want to avoid putting the same items multiple times.
 *                   This can be null.
 * @param resultOut {@link Result} instance
 * @throws RepositoryException if repository exception occurs
 */
public static void fillResultItemsFromQueries(Session session, Collection<String> queries, boolean binary,
        Set<String> pathsCache, Result resultOut) throws RepositoryException {
    for (String query : queries) {
        if (StringUtils.isBlank(query)) {
            continue;
        }

        if (!StringUtils.startsWith(query, "/") || StringUtils.startsWithIgnoreCase(query, "select")) {
            continue;
        }

        final String language = (StringUtils.startsWithIgnoreCase(query, "select")) ? Query.SQL : Query.XPATH;
        Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(query, language);
        QueryResult queryResult = jcrQuery.execute();

        for (NodeIterator nodeIt = queryResult.getNodes(); nodeIt.hasNext();) {
            Node node = nodeIt.nextNode();

            if (node == null) {
                continue;
            }

            String nodePath = node.getPath();

            if ((binary && !HippoNodeUtils.isBinaryPath(nodePath))
                    || (!binary && !HippoNodeUtils.isDocumentPath(nodePath))) {
                continue;
            }

            Node handle = HippoNodeUtils.getHippoDocumentHandle(node);

            if (handle == null) {
                continue;
            }

            String handlePath = handle.getPath();

            if (pathsCache.contains(handlePath)) {
                continue;
            }

            Node firstVariant = HippoNodeUtils.getFirstVariantNode(handle);

            if (firstVariant == null) {
                continue;
            }

            pathsCache.add(handlePath);
            ResultItem item = new ResultItem(handlePath, firstVariant.getPrimaryNodeType().getName());
            resultOut.addItem(item);
        }
    }
}