Projects >> yanel >>ec67e88f5941c22f42bb120288566fb83aa0721d

Chunk
Conflicting content
            uid.appendChild(doc.createTextNode(username));
        }

<<<<<<< HEAD
        //javax.servlet.http.Cookie cookie = org.wyona.yanel.servlet.AccessLog.getYanelAnalyticsCookie(getEnvironment().getRequest(), getEnvironment().getResponse());
        javax.servlet.http.Cookie cookie = org.wyona.yanel.servlet.AccessLog.getYanelAnalyticsCookie(getEnvironment().getRequest());
        if (cookie != null) {
            Date lastAccess = getLastAccess(cookie.getValue(), "www.yanel.org");
            java.text.DateFormat df = new java.text.SimpleDateFormat("yyyyMMdd");

            rootEl.setAttributeNS(NAMESPACE, "cookie-id", cookie.getValue());
            rootEl.setAttributeNS(NAMESPACE, "last-access", df.format(lastAccess));

            org.w3c.dom.Element sinceLastAccessEl = doc.createElementNS(NAMESPACE, "since-last-access");
            rootEl.appendChild(sinceLastAccessEl);

            org.w3c.dom.Element beforeLastAccessEl = doc.createElementNS(NAMESPACE, "before-last-access");
            rootEl.appendChild(beforeLastAccessEl);

            String[] userInterests = getUserInterests(cookie.getValue());
            if (userInterests != null && userInterests.length > 0) {
                for (int k = 0; k < userInterests.length; k++) {
                    //String queryInclModDate = userInterests[k] + " AND mod_date:[" + df.format(lastAccess) + " TO " + df.format(new Date()) + "]"; // INFO: See http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Range%20Searches
                    String queryInclModDate = userInterests[k] + " AND yarep_lastModified:[" + lastAccess.getTime() + " TO " + new Date().getTime() + "]"; // INFO: See http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Range%20Searches
                    log.debug("Query: " + queryInclModDate);

                    org.wyona.yarep.core.Node[] nodesInclModDate = getRealm().getRepository().getSearcher().search(queryInclModDate);

                    if (nodesInclModDate != null && nodesInclModDate.length > 0) {
                        for (int i = 0; i < nodesInclModDate.length; i++) {
                            org.w3c.dom.Element result = doc.createElementNS(NAMESPACE, "result");
                            result.setAttributeNS(NAMESPACE, "node-path", nodesInclModDate[i].getPath());
                            result.setAttributeNS(NAMESPACE, "node-last-modified", "" + new Date(nodesInclModDate[i].getLastModified()));
                            result.setAttributeNS(NAMESPACE, "interest", userInterests[k]);
                            sinceLastAccessEl.appendChild(result);
                        }
                    } else {
                        org.w3c.dom.Element noResults = doc.createElementNS(NAMESPACE, "no-results");
                        noResults.setAttributeNS(NAMESPACE, "interest", userInterests[k]);
                        sinceLastAccessEl.appendChild(noResults);
                    }

                    String query = userInterests[k];
                    org.wyona.yarep.core.Node[] nodes = getRealm().getRepository().getSearcher().search(query);
                    if (nodes != null && nodes.length > 0) {
                        for (int i = 0; i < nodes.length; i++) {
            exceptionEl.appendChild(doc.createTextNode(e.getMessage()));
            root.appendChild(exceptionEl);
                            if (nodes[i].getLastModified() < lastAccess.getTime()) {
                                org.w3c.dom.Element result = doc.createElementNS(NAMESPACE, "result");
                                result.setAttributeNS(NAMESPACE, "node-path", nodes[i].getPath());
                                result.setAttributeNS(NAMESPACE, "node-last-modified", "" + new Date(nodes[i].getLastModified()));
                                result.setAttributeNS(NAMESPACE, "interest", userInterests[k]);
                                beforeLastAccessEl.appendChild(result);
                            }
                        }
                    } else {
                        org.w3c.dom.Element noResults = doc.createElementNS(NAMESPACE, "no-results");
                        noResults.setAttributeNS(NAMESPACE, "interest", userInterests[k]);
                        beforeLastAccessEl.appendChild(noResults);
                    }
                }
            } else {
                rootEl.appendChild(doc.createElementNS(NAMESPACE, "no-user-interests"));
=======
        String realm = getRealm().getID();
        String boost_domain = getRealm().getUserTrackingDomain();
        Element realmEl = doc.createElementNS(NAMESPACE, "yanel-realm-id");
        realmEl.appendChild(doc.createTextNode(realm));
        root.appendChild(realmEl);
        Element domainEl = doc.createElementNS(NAMESPACE, "boost-domain-id");
        domainEl.appendChild(doc.createTextNode(boost_domain));
        root.appendChild(domainEl);

        // Get the cookie
        HttpServletRequest req = getEnvironment().getRequest();
        Cookie cookie = AccessLog.getYanelAnalyticsCookie(req);

        if(cookie == null) {
            root.appendChild(doc.createElementNS(NAMESPACE, "no-cookie"));
            root.appendChild(doc.createElementNS(NAMESPACE, "no-profile"));
            return XMLHelper.getInputStream(doc, false, false, null);
        }

        Element cookieEl = doc.createElementNS(NAMESPACE, "yanel-cookie-id");
        cookieEl.appendChild(doc.createTextNode(cookie.getValue()));
        root.appendChild(cookieEl);

        Iterable userInterests;
        try {
            userInterests = getUserInterests(cookie.getValue(), boost_domain);
        } catch(ServiceException e) {
            // No interests
            log.error(e, e);

            Element exceptionEl = doc.createElementNS(NAMESPACE, "exception");

            Element errEl = doc.createElementNS(NAMESPACE, "no-profile");
            root.appendChild(errEl);
            return XMLHelper.getInputStream(doc, false, false, null);
        }

        // Add all interests to user profile
        Element interestsEl = doc.createElementNS(NAMESPACE, "interests");
        for(String interest : userInterests) {
            Element interestEl = doc.createElementNS(NAMESPACE, "interest");
            interestEl.appendChild(doc.createTextNode(interest));
            interestsEl.appendChild(interestEl);
        }
        root.appendChild(interestsEl);

        // Search for related content in data repository
        Element resultsEl = doc.createElementNS(NAMESPACE, "results");
        Searcher search = getRealm().getRepository().getSearcher();
        for(String interest : userInterests) {
            Node[] nodes;

            try {
                nodes = search.search(interest);
            } catch(Exception e) {
                break;
            }

            for(Node node : nodes) {
                Element res_node = doc.createElementNS(NAMESPACE, "result");
                Element res_path = doc.createElementNS(NAMESPACE, "path");
                Element res_name = doc.createElementNS(NAMESPACE, "name");
                Element res_time = doc.createElementNS(NAMESPACE, "last-modified");

                res_path.appendChild(doc.createTextNode(node.getPath()));
                res_name.appendChild(doc.createTextNode(node.getName()));
                res_time.appendChild(doc.createTextNode(Long.toString(node.getLastModified())));
                res_node.appendChild(res_path);

                resultsEl.appendChild(res_node);
>>>>>>> 905e84fdaeb3fb20d6b3a833aa2b5e43cd7bb0dc
            }
        }
        root.appendChild(resultsEl);
Solution content
            uid.appendChild(doc.createTextNode(username));
        }

        String realm = getRealm().getID();
        String boost_domain = getRealm().getUserTrackingDomain();
        Element realmEl = doc.createElementNS(NAMESPACE, "yanel-realm-id");
        realmEl.appendChild(doc.createTextNode(realm));
        root.appendChild(realmEl);
        Element domainEl = doc.createElementNS(NAMESPACE, "boost-domain-id");
        domainEl.appendChild(doc.createTextNode(boost_domain));
        root.appendChild(domainEl);

        // Get the cookie
        HttpServletRequest req = getEnvironment().getRequest();
        Cookie cookie = AccessLog.getYanelAnalyticsCookie(req);

        if(cookie == null) {
            root.appendChild(doc.createElementNS(NAMESPACE, "no-cookie"));
            root.appendChild(doc.createElementNS(NAMESPACE, "no-profile"));
            return XMLHelper.getInputStream(doc, false, false, null);
        }

        Element cookieEl = doc.createElementNS(NAMESPACE, "yanel-cookie-id");
        cookieEl.appendChild(doc.createTextNode(cookie.getValue()));
        root.appendChild(cookieEl);

        Iterable userInterests;
        try {
            userInterests = getUserInterests(cookie.getValue(), boost_domain);
        } catch(ServiceException e) {
            // No interests
            log.error(e, e);

            Element exceptionEl = doc.createElementNS(NAMESPACE, "exception");
            exceptionEl.appendChild(doc.createTextNode(e.getMessage()));
            root.appendChild(exceptionEl);

            Element errEl = doc.createElementNS(NAMESPACE, "no-profile");
            root.appendChild(errEl);
            return XMLHelper.getInputStream(doc, false, false, null);
        }

        // Add all interests to user profile
        Element interestsEl = doc.createElementNS(NAMESPACE, "interests");
        for(String interest : userInterests) {
            Element interestEl = doc.createElementNS(NAMESPACE, "interest");
            interestEl.appendChild(doc.createTextNode(interest));
            interestsEl.appendChild(interestEl);
        }
        root.appendChild(interestsEl);

        // Search for related content in data repository
        Element resultsEl = doc.createElementNS(NAMESPACE, "results");
        Searcher search = getRealm().getRepository().getSearcher();
        for(String interest : userInterests) {
            Node[] nodes;

            try {
                nodes = search.search(interest);
            } catch(Exception e) {
                break;
            }

            for(Node node : nodes) {
                Element res_node = doc.createElementNS(NAMESPACE, "result");
                Element res_path = doc.createElementNS(NAMESPACE, "path");
                Element res_name = doc.createElementNS(NAMESPACE, "name");
                Element res_time = doc.createElementNS(NAMESPACE, "last-modified");

                res_path.appendChild(doc.createTextNode(node.getPath()));
                res_name.appendChild(doc.createTextNode(node.getName()));
                res_time.appendChild(doc.createTextNode(Long.toString(node.getLastModified())));
                res_node.appendChild(res_path);

                resultsEl.appendChild(res_node);
            }
        }
        root.appendChild(resultsEl);
File
PersonalizedContentResource.java
Developer's decision
Version 2
Kind of conflict
Comment
For statement
If statement
Method invocation
Try statement
Variable