Search in sources :

Example 1 with CsJssFilesDetails

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

the class CombineCsJssImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    CombineCsJssResult result = new CombineCsJssResult();
    // Changes for US432336
    List<CsJssFilesDetails> fileDetails = new ArrayList<CsJssFilesDetails>();
    int inefficientCssRequests = 0;
    PacketInfo consecutiveCssJsFirstPacket = null;
    int inefficientJsRequests = 0;
    double cssLastTimeStamp = 0.0;
    double jsLastTimeStamp = 0.0;
    String contentType = "";
    for (Session session : tracedata.getSessionlist()) {
        HttpRequestResponseInfo lastRequestObj = null;
        for (HttpRequestResponseInfo httpreq : session.getRequestResponseInfo()) {
            if (httpreq.getDirection() == HttpDirection.REQUEST) {
                lastRequestObj = httpreq;
            }
            if (httpreq.getDirection() == HttpDirection.RESPONSE && httpreq.getContentType() != null) {
                PacketInfo pktInfo = httpreq.getFirstDataPacket();
                if (pktInfo != null) {
                    contentType = httpreq.getContentType().toLowerCase().trim();
                    if (contentType.equalsIgnoreCase("text/css")) {
                        if (cssLastTimeStamp == 0.0) {
                            cssLastTimeStamp = pktInfo.getTimeStamp();
                            continue;
                        } else {
                            if ((pktInfo.getTimeStamp() - cssLastTimeStamp) <= 2.0) {
                                inefficientCssRequests++;
                                // Changes for US432336
                                CsJssFilesDetails cssFileDetails = new CsJssFilesDetails();
                                cssFileDetails.setTimeStamp(pktInfo.getTimeStamp());
                                if (httpreq.getObjName() != null) {
                                    cssFileDetails.setFileName(httpreq.getObjName());
                                } else {
                                    if (lastRequestObj != null) {
                                        cssFileDetails.setFileName(lastRequestObj.getObjName());
                                    }
                                }
                                cssFileDetails.setSize(httpreq.getContentLength());
                                fileDetails.add(cssFileDetails);
                                if (consecutiveCssJsFirstPacket == null) {
                                    consecutiveCssJsFirstPacket = pktInfo;
                                }
                            }
                            cssLastTimeStamp = pktInfo.getTimeStamp();
                        }
                    } else if (contentType.equalsIgnoreCase("text/javascript") || contentType.equalsIgnoreCase("application/x-javascript") || contentType.equalsIgnoreCase("application/javascript")) {
                        if (jsLastTimeStamp == 0.0) {
                            jsLastTimeStamp = pktInfo.getTimeStamp();
                            continue;
                        } else {
                            if ((pktInfo.getTimeStamp() - jsLastTimeStamp) < 2.0) {
                                inefficientJsRequests++;
                                // Changes for US432336
                                CsJssFilesDetails jsFileDetails = new CsJssFilesDetails();
                                jsFileDetails.setTimeStamp(pktInfo.getTimeStamp());
                                if (httpreq.getObjName() != null) {
                                    jsFileDetails.setFileName(httpreq.getObjName());
                                } else {
                                    if (lastRequestObj != null) {
                                        jsFileDetails.setFileName(lastRequestObj.getObjName());
                                    }
                                }
                                jsFileDetails.setSize(httpreq.getContentLength());
                                fileDetails.add(jsFileDetails);
                                if (consecutiveCssJsFirstPacket == null) {
                                    consecutiveCssJsFirstPacket = pktInfo;
                                }
                            }
                            jsLastTimeStamp = pktInfo.getTimeStamp();
                        }
                    }
                }
            }
        }
    }
    result.setConsecutiveCssJsFirstPacket(consecutiveCssJsFirstPacket);
    result.setInefficientCssRequests(inefficientCssRequests);
    result.setInefficientJsRequests(inefficientJsRequests);
    if (inefficientCssRequests < 1 && inefficientJsRequests < 1) {
        result.setResultType(BPResultType.PASS);
        result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName()));
    } else {
        result.setResultType(BPResultType.FAIL);
        result.setResultText(textResults);
        // Changes for US432336
        result.setFilesDetails(fileDetails);
    }
    result.setResultExcelText(result.getResultType().getDescription());
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllInefficientCssRequest(exportAllInefficientCssRequest);
    result.setExportAllInefficientJsRequest(exportAllInefficientJsRequest);
    return result;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) CombineCsJssResult(com.att.aro.core.bestpractice.pojo.CombineCsJssResult) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) CsJssFilesDetails(com.att.aro.core.bestpractice.pojo.CsJssFilesDetails) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

CombineCsJssResult (com.att.aro.core.bestpractice.pojo.CombineCsJssResult)1 CsJssFilesDetails (com.att.aro.core.bestpractice.pojo.CsJssFilesDetails)1 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 ArrayList (java.util.ArrayList)1