Search in sources :

Example 16 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class RequestResponseDetailsPanel method getJRequestResponseTable.

/**
 * Initializes and returns the the DataTable that contains Http request and
 * response informations.
 */
public DataTable<HttpRequestResponseInfo> getJRequestResponseTable() {
    if (jRequestResponseTable == null) {
        jRequestResponseTable = new DataTable<HttpRequestResponseInfo>(jRequestResponseTableModel);
        jRequestResponseTable.setName(ResourceBundleHelper.getMessageString("diagnostics.request.response.view.tableName"));
        jRequestResponseTable.setAutoCreateRowSorter(true);
        jRequestResponseTable.setGridColor(Color.LIGHT_GRAY);
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) jRequestResponseTable.getPopup();
        popupMenu.initialize();
        jRequestResponseTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent event) {
                // Enable view and save as buttons appropriately
                HttpRequestResponseInfo httpRRInfo = jRequestResponseTable.getSelectedItem();
                boolean validResponse = httpRRInfo != null && httpRRInfo.getContentLength() > 0 && httpRRInfo.getDirection() == HttpDirection.RESPONSE && httpRRInfo.getStatusCode() != 0;
                boolean isVideo = (validResponse) ? ((httpRRInfo != null && httpRRInfo.getContentType() != null) ? httpRRInfo.getContentType().contains("video/") : false) : false;
                boolean isApplicationZip = httpRRInfo != null && httpRRInfo.getContentType() != null && httpRRInfo.getContentType().contains("application/zip");
                boolean isContentTypeAvailable = httpRRInfo != null && httpRRInfo.getContentType() != null;
                getViewBtn().setEnabled(!isApplicationZip && !isVideo && validResponse && isContentTypeAvailable);
                getSaveBtn().setEnabled(!isApplicationZip && validResponse && isContentTypeAvailable);
            }
        });
        jRequestResponseTable.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent event) {
                if (event.getClickCount() == 2 && getViewBtn().isEnabled()) {
                    try {
                        viewContent(jRequestResponseTable.getSelectedItem());
                    } catch (Exception e) {
                        LOG.error("Failed to open the content in the view window with unexpected error", e);
                        new MessageDialogFactory().showPlainDialog(RequestResponseDetailsPanel.this.getTopLevelAncestor(), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Message"), ResourceBundleHelper.getMessageString("view.requestresponsedetails.error.Title"));
                    }
                }
            }
        });
    }
    return jRequestResponseTable;
}
Also used : MouseEvent(java.awt.event.MouseEvent) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 17 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ExportSessionData method getRequestResponseData.

private List<List<Object>> getRequestResponseData() {
    List<List<Object>> requestResponseData = new ArrayList<>();
    sessionMap.forEach((sessionKey, sessionData) -> {
        for (HttpRequestResponseInfo httpRequestResponseInfo : reqRespMap.get(sessionKey)) {
            List<Object> data = new ArrayList<>(sessionData);
            data.add(httpRequestResponseInfo.getTimeStamp());
            data.add(httpRequestResponseInfo.getDirection());
            if (httpRequestResponseInfo.getDirection() == HttpDirection.REQUEST) {
                String type = httpRequestResponseInfo.getRequestType();
                data.add(type != null ? type : ResourceBundleHelper.getMessageString("rrview.unknownType"));
            } else {
                data.add(httpRequestResponseInfo.getStatusCode() != 0 ? httpRequestResponseInfo.getStatusCode() : ResourceBundleHelper.getMessageString("rrview.unknownType"));
            }
            if (httpRequestResponseInfo.getDirection() == HttpDirection.REQUEST) {
                data.add(httpRequestResponseInfo.getHostName());
            } else {
                data.add(httpRequestResponseInfo.getContentType());
            }
            if (httpRequestResponseInfo.getDirection() == HttpDirection.REQUEST) {
                data.add(StringUtils.isNotEmpty(httpRequestResponseInfo.getObjName()) ? httpRequestResponseInfo.getObjName() : httpRequestResponseInfo.getContentLength());
            } else {
                data.add(httpRequestResponseInfo.getContentLength());
            }
            data.add(httpRequestResponseInfo.getRawSize());
            data.add(getHttpCompression(httpRequestResponseInfo));
            requestResponseData.add(data);
        }
    });
    return requestResponseData;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ImageMetaDataImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    ImageMdtaResult result = new ImageMdtaResult();
    List<String> imageList = new ArrayList<String>();
    List<ImageMdataEntry> entrylist = new ArrayList<ImageMdataEntry>();
    String imagePath = tracedata.getTraceresult().getTraceDirectory() + System.getProperty("file.separator") + "Image" + System.getProperty("file.separator");
    if (Util.isFilesforAnalysisAvailable(new File(imagePath))) {
        for (Session session : tracedata.getSessionlist()) {
            for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
                if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
                    String extractedImageName = ImageHelper.extractFullNameFromRRInfo(req);
                    int pos = extractedImageName.lastIndexOf('.') + 1;
                    // List<String> imageList = new ArrayList<String>();
                    File folder = new File(imagePath);
                    File[] listOfFiles = folder.listFiles();
                    if (listOfFiles != null) {
                        runTestForFiles(imageList, entrylist, session, req, imagePath, extractedImageName, pos, listOfFiles);
                    }
                }
            }
        }
        result.setResults(entrylist);
        String text = "";
        if (entrylist.isEmpty()) {
            result.setResultType(BPResultType.PASS);
            text = MessageFormat.format(textResultPass, entrylist.size());
            result.setResultText(text);
            result.setResultExcelText(BPResultType.PASS.getDescription());
        } else {
            result.setResultType(BPResultType.FAIL);
            text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), entrylist.size());
            result.setResultText(text);
            result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), entrylist.size()));
        }
    } else {
        result.setResultText(noData);
        result.setResultExcelText(BPResultType.NO_DATA.getDescription());
        result.setResultType(BPResultType.NO_DATA);
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportNumberOfMdataImages(String.valueOf(entrylist.size()));
    return result;
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) ByteSourceFile(org.apache.commons.imaging.common.bytesource.ByteSourceFile) ImageMdtaResult(com.att.aro.core.bestpractice.pojo.ImageMdtaResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 19 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ImageUIComparatorImpl method getImageList.

private void getImageList() {
    String originalImageName = "";
    long orgImageSize = 0L;
    String imgExtn = "";
    for (Session session : tracedataResult.getSessionlist()) {
        for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
            if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
                originalImageName = Util.extractFullNameFromRequest(reqResp);
                if (!originalImageName.isEmpty()) {
                    File orgImage = new File(imageFolderPath + originalImageName);
                    orgImageSize = orgImage.length();
                    int pos = originalImageName.lastIndexOf(".");
                    imgExtn = originalImageName.substring(pos + 1, originalImageName.length());
                    if (orgImageSize > 0 && Util.isJPG(orgImage, imgExtn)) {
                        updateOriginalImageDimensionMap(originalImageName, imgExtn, pos, reqResp);
                    }
                }
            }
        }
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 20 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ImageFormatImpl method getEntryList.

private List<ImageMdataEntry> getEntryList() {
    String originalImage = "";
    long convertedImgSize = 0L;
    long orgImageSize = 0L;
    String imgExtn = "";
    long orgImgSize;
    long convImageSize;
    String convImage = "";
    String convertedImagesFolderPath = "";
    List<ImageMdataEntry> imgEntryList = new ArrayList<ImageMdataEntry>();
    for (Session session : tracedataResult.getSessionlist()) {
        for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
            if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
                originalImage = ImageHelper.extractFullNameFromRRInfo(reqResp);
                if ((!originalImage.isEmpty() && !(originalImage.contains(".jpeg") || originalImage.contains(".jpg"))) && reqResp.getContentType().contains("jpeg")) {
                    originalImage = Util.parseImageName(originalImage, reqResp);
                }
                File orgImage = new File(imageFolderPath + originalImage);
                orgImageSize = orgImage.length();
                int pos = originalImage.lastIndexOf(".");
                imgExtn = originalImage.substring(pos + 1, originalImage.length());
                if (orgImageSize > 0 && Util.isJPG(orgImage, imgExtn)) {
                    convertedImagesFolderPath = imageFolderPath + "Format" + System.getProperty("file.separator");
                    convImage = convertedImagesFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".") + 1) + convExtn;
                    convertedImgSize = new File(convImage).length();
                    long indSavings = (orgImageSize - convertedImgSize) * 100 / orgImageSize;
                    if (convertedImgSize > 0 && (indSavings >= 15)) {
                        orginalImagesSize = orginalImagesSize + orgImageSize;
                        convImgsSize = convImgsSize + convertedImgSize;
                        orgImgSize = orgImageSize / 1024;
                        convImageSize = convertedImgSize / 1024;
                        imgEntryList.add(new ImageMdataEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, orgImgSize, convImageSize, Long.toString(indSavings)));
                    }
                }
            }
        }
    }
    return imgEntryList;
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4