Search in sources :

Example 1 with EmptyUrlResult

use of com.att.aro.core.bestpractice.pojo.EmptyUrlResult in project VideoOptimzer by attdevsupport.

the class ARODiagnosticsOverviewRouteImpl method routeHyperlink.

@Override
public void routeHyperlink(BestPracticeType bpType) {
    if (bpType.equals(BestPracticeType.DUPLICATE_CONTENT)) {
        jtabbedPane.setSelectedIndex(OVERVIEW_INDEX);
    } else {
        jtabbedPane.setSelectedIndex(DIAGNOSTIC_INDEX);
        DiagnosticsTab diagnosticsTab = (DiagnosticsTab) jtabbedPane.getSelectedComponent();
        switch(bpType) {
            case FILE_COMPRESSION:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof FileCompressionResult) {
                // diagnosticsTab.setHighlightedTCP(((FileCompressionResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            // break;
            case USING_CACHE:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof UsingCacheResult) {
                            diagnosticsTab.setHighlightedTCP(((UsingCacheResult) result).getNoCacheHeaderFirstPacket().getTimeStamp());
                            break;
                        }
                    }
                }
                break;
            case CACHE_CONTROL:
                {
                // cant not find cache control start time in
                // CacheControlResult
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof CacheControlResult) {
                // diagnosticsTab.setHighlightedTCP(((CacheControlResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case COMBINE_CS_JSS:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof CombineCsJssResult) {
                            diagnosticsTab.setHighlightedTCP(((CombineCsJssResult) result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                            break;
                        }
                    }
                }
                break;
            case IMAGE_SIZE:
                {
                }
                break;
            case IMAGE_MDATA:
                {
                }
                break;
            case IMAGE_CMPRS:
                {
                }
                break;
            case IMAGE_FORMAT:
                {
                }
                break;
            case IMAGE_COMPARE:
                {
                }
                break;
            case MINIFICATION:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof CombineCsJssResult) {
                // diagnosticsTab.setHighlightedTCP(((MinificationResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case SPRITEIMAGE:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof SpriteImageResult) {
                // diagnosticsTab.setHighlightedTCP(((SpriteImageResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case UNNECESSARY_CONNECTIONS:
                {
                    // to test
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof UnnecessaryConnectionResult) {
                            diagnosticsTab.setHighlightedTCP(((UnnecessaryConnectionResult) result).getTightlyCoupledBurstTime());
                            break;
                        }
                    }
                }
                break;
            case SCRIPTS_URL:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof ScriptsResult) {
                            diagnosticsTab.setHighlightedTCP(((ScriptsResult) result).getFirstFailedHtml());
                            break;
                        }
                    }
                }
                break;
            case SCREEN_ROTATION:
                {
                }
                break;
            case SIMUL_CONN:
                {
                }
                break;
            case MULTI_SIMULCONN:
                {
                }
                break;
            case PERIODIC_TRANSFER:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof PeriodicTransferResult) {
                            diagnosticsTab.setHighlightedTCP(((PeriodicTransferResult) result).getMinimumPeriodicRepeatTime());
                            break;
                        }
                    }
                }
                break;
            case HTTP_4XX_5XX:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof Http4xx5xxResult) {
                // diagnosticsTab.setHighlightedTCP(((Http4xx5xxResult)result).getHttpResCodelist()ConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case HTTP_3XX_CODE:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof Http3xxCodeResult) {
                // diagnosticsTab.setHighlightedTCP(((Http3xxCodeResult)result).getFirstResMap()ConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case HTTP_1_0_USAGE:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof Http10UsageResult) {
                            diagnosticsTab.setHighlightedTCP(((Http10UsageResult) result).getHttp10Session());
                            break;
                        }
                    }
                }
                break;
            case FILE_ORDER:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof FileOrderResult) {
                // diagnosticsTab.setHighlightedTCP(((FileOrderResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case EMPTY_URL:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof EmptyUrlResult) {
                            diagnosticsTab.setHighlightedTCP(((EmptyUrlResult) result).getFirstFailedHtml());
                            break;
                        }
                    }
                }
                break;
            case DISPLAY_NONE_IN_CSS:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof DisplayNoneInCSSResult) {
                // diagnosticsTab.setHighlightedTCP(((DisplayNoneInCSSResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case CONNECTION_OPENING:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof ConnectionOpeningResult) {
                // diagnosticsTab.setHighlightedTCP(((ConnectionOpeningResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case CONNECTION_CLOSING:
                {
                    // done
                    for (AbstractBestPracticeResult result : diagnosticsTab.getAnalyzerResult().getBestPracticeResults()) {
                        if (result instanceof ConnectionClosingResult) {
                            diagnosticsTab.setHighlightedTCP(((ConnectionClosingResult) result).getLargestEnergyTime());
                            break;
                        }
                    }
                }
                break;
            case ASYNC_CHECK:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof AsyncCheckInScriptResult) {
                // diagnosticsTab.setHighlightedTCP(((AsyncCheckInScriptResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            case ACCESSING_PERIPHERALS:
                {
                // for (AbstractBestPracticeResult result :
                // diagnosticsTab.getAnalyzerResult().getBestPracticeResults())
                // {
                // if (result instanceof AccessingPeripheralResult) {
                // diagnosticsTab.setHighlightedTCP(((AccessingPeripheralResult)result).getConsecutiveCssJsFirstPacket().getTimeStamp());
                // break;
                // }
                // }
                }
                break;
            default:
                break;
        }
    // switch
    }
}
Also used : UnnecessaryConnectionResult(com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult) ConnectionClosingResult(com.att.aro.core.bestpractice.pojo.ConnectionClosingResult) Http10UsageResult(com.att.aro.core.bestpractice.pojo.Http10UsageResult) PeriodicTransferResult(com.att.aro.core.bestpractice.pojo.PeriodicTransferResult) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) ScriptsResult(com.att.aro.core.bestpractice.pojo.ScriptsResult) CombineCsJssResult(com.att.aro.core.bestpractice.pojo.CombineCsJssResult) DiagnosticsTab(com.att.aro.ui.view.diagnostictab.DiagnosticsTab) EmptyUrlResult(com.att.aro.core.bestpractice.pojo.EmptyUrlResult) UsingCacheResult(com.att.aro.core.bestpractice.pojo.UsingCacheResult)

Example 2 with EmptyUrlResult

use of com.att.aro.core.bestpractice.pojo.EmptyUrlResult in project VideoOptimzer by attdevsupport.

the class EmptyUrlImpl method analyzeHtml.

private EmptyUrlResult analyzeHtml(HttpRequestResponseInfo request, Session session, EmptyUrlResult result) {
    EmptyUrlResult res = result;
    Document htmlDoc = null;
    String contentstr = null;
    try {
        contentstr = reqhelper.getContentString(request, session);
    } catch (Exception e) {
        LOG.error("Failed to get content from HttpRequestResponseInfo", e);
        return res;
    }
    Elements allSrcElements = new Elements();
    try {
        htmlDoc = Jsoup.parse(contentstr);
        allSrcElements.addAll(htmlDoc.select("iframe"));
        allSrcElements.addAll(htmlDoc.select("img"));
        allSrcElements.addAll(htmlDoc.select("script"));
        allSrcElements.addAll(htmlDoc.select("a"));
        allSrcElements.addAll(htmlDoc.select("link"));
    } catch (Exception e) {
        LOG.error("Failed to parse :" + contentstr, e);
    }
    res = checkAttributeEmpty(request, allSrcElements, res);
    return res;
}
Also used : EmptyUrlResult(com.att.aro.core.bestpractice.pojo.EmptyUrlResult) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 3 with EmptyUrlResult

use of com.att.aro.core.bestpractice.pojo.EmptyUrlResult in project VideoOptimzer by attdevsupport.

the class EmptyUrlImpl method checkAttributeEmpty.

private EmptyUrlResult checkAttributeEmpty(HttpRequestResponseInfo rreq, Elements elements, EmptyUrlResult input) {
    EmptyUrlResult result = input;
    int numberOfFailedFiles = result.getNumberOfFailedFiles();
    for (Element element : elements) {
        if ((element.hasAttr("href") && element.attr("href").isEmpty()) || (element.hasAttr("src") && element.attr("src").isEmpty())) {
            // store the 1st occurrence
            if (result.getFirstFailedHtml() == null) {
                result.setFirstFailedHtml(rreq);
            }
            numberOfFailedFiles++;
            // log.info("numberOfFailedFiles:"+ numberOfFailedFiles);
            result.setNumberOfFailedFiles(numberOfFailedFiles);
        }
    }
    return result;
}
Also used : Element(org.jsoup.nodes.Element) EmptyUrlResult(com.att.aro.core.bestpractice.pojo.EmptyUrlResult)

Example 4 with EmptyUrlResult

use of com.att.aro.core.bestpractice.pojo.EmptyUrlResult in project VideoOptimzer by attdevsupport.

the class EmptyUrlImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    EmptyUrlResult result = new EmptyUrlResult();
    for (Session session : tracedata.getSessionlist()) {
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getContentType() != null && reqhelper.isHtml(req.getContentType()) && req.getContentLength() > 0 && req.getDirection() == HttpDirection.RESPONSE) {
                result = analyzeHtml(req, session, result);
            }
        }
    }
    String text = "";
    if (result.getFirstFailedHtml() == null) {
        result.setResultType(BPResultType.PASS);
        text = MessageFormat.format(this.textResultPass, result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        text = MessageFormat.format(textResults, result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultType(BPResultType.FAIL);
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), result.getNumberOfFailedFiles()));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllEmptyUrlFiles(exportAllEmptyUrlFiles);
    return result;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) EmptyUrlResult(com.att.aro.core.bestpractice.pojo.EmptyUrlResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

EmptyUrlResult (com.att.aro.core.bestpractice.pojo.EmptyUrlResult)4 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)1 CombineCsJssResult (com.att.aro.core.bestpractice.pojo.CombineCsJssResult)1 ConnectionClosingResult (com.att.aro.core.bestpractice.pojo.ConnectionClosingResult)1 Http10UsageResult (com.att.aro.core.bestpractice.pojo.Http10UsageResult)1 PeriodicTransferResult (com.att.aro.core.bestpractice.pojo.PeriodicTransferResult)1 ScriptsResult (com.att.aro.core.bestpractice.pojo.ScriptsResult)1 UnnecessaryConnectionResult (com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult)1 UsingCacheResult (com.att.aro.core.bestpractice.pojo.UsingCacheResult)1 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 DiagnosticsTab (com.att.aro.ui.view.diagnostictab.DiagnosticsTab)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1