Package org.apache.commons.compress.archivers.zip

Examples of org.apache.commons.compress.archivers.zip.ZipFile$Entry


        // We can only detect the exact type when given a TikaInputStream
        TikaInputStream tis = TikaInputStream.cast(input);
        if (tis != null) {
            try {
                ZipFile zip = new ZipFile(tis.getFile());
                try {
                    MediaType type = detectOpenDocument(zip);
                    if (type == null) {
                        type = detectOfficeOpenXML(zip, tis);
                    }
                    if (type == null) {
                        type = detectIWork(zip);
                    }
                    if (type != null) {
                        return type;
                    } else if (zip.getEntry("META-INF/MANIFEST.MF") != null) {
                        return MediaType.application("java-archive");
                    }
                } finally {
                    // TODO: shouldn't we record the open
                    // container so it can be later
                    // reused...?
                    // tis.setOpenContainer(zip);
                    zip.close();
                }
            } catch (IOException ignore) {
            }
        }
View Full Code Here


            return MediaType.APPLICATION_ZIP;
        }

        try {
            File file = TikaInputStream.get(input).getFile();
            ZipFile zip = new ZipFile(file);

            MediaType type = detectOpenDocument(zip);
            if (type == null) {
                type = detectOfficeOpenXML(zip, TikaInputStream.get(input));
            }
            if (type == null) {
                type = detectIWork(zip);
            }
            if (type == null && zip.getEntry("META-INF/MANIFEST.MF") != null) {
                type = MediaType.application("java-archive");
            }
            if (type == null) {
                type = MediaType.APPLICATION_ZIP;
            }
View Full Code Here

    }

  protected Map<String, String> readZipArchive(InputStream inputStream) throws IOException {
    Map<String, String> data = new HashMap<String, String>();
    File tempFile = writeTemporaryArchiveFile(inputStream, "zip");
        ZipFile zip = new ZipFile(tempFile);
        Enumeration<ZipArchiveEntry> entries = zip.getEntries();
        while (entries.hasMoreElements()) {
          ZipArchiveEntry entry = entries.nextElement();
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          IOUtils.copy(zip.getInputStream(entry), bos);
          data.put(entry.getName(), DigestUtils.md5Hex(bos.toByteArray()));
        }

        zip.close();
        tempFile.delete();
    return data;
  }
View Full Code Here

    return data;
  }

  protected String readArchiveText(InputStream inputStream) throws IOException {
      File tempFile = writeTemporaryArchiveFile(inputStream, "zip");
      ZipFile zip = new ZipFile(tempFile);
      zip.getEntry(UnpackerResource.TEXT_FILENAME);
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
        IOUtils.copy(zip.getInputStream(zip.getEntry(UnpackerResource.TEXT_FILENAME)), bos);

        zip.close();
        tempFile.delete();
    return bos.toString("UTF-8");
  }
View Full Code Here

        }
    }

    private static MediaType detectZipFormat(TikaInputStream tis) {
        try {
            ZipFile zip = new ZipFile(tis.getFile()); // TODO: hasFile()?
            try {
                MediaType type = detectOpenDocument(zip);
                if (type == null) {
                    type = detectOPCBased(zip, tis);
                }
                if (type == null) {
                    type = detectIWork(zip);
                }
                if (type == null) {
                    type = detectJar(zip);
                }
                if (type == null) {
                    type = detectKmz(zip);
                }
                if (type == null) {
                    type = detectIpa(zip);
                }
                if (type != null) {
                    return type;
                }
            } finally {
                // TODO: shouldn't we record the open
                // container so it can be later
                // reused...?
                // tis.setOpenContainer(zip);
                try {
                    zip.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        } catch (IOException e) {
View Full Code Here

                    for (TestMethod testMethod : inputTestData.getTestMethod()) {
                        List<TestRecord> originalTestRecords = testMethod.getTestRecord();
                        for (TestRecord originalTestRecord : originalTestRecords) {
                            if (originalTestRecord.getId().equals(testRecord.get(RECORD_POSITION))) {
                                OutputData outputData = new OutputData();
                                Entry outputEntry = new Entry();
                                outputEntry.setKey(ACTUAL_RESULT);
                                outputEntry.setValue(testRecord.get(ACTUAL_RESULT).toString());
                                outputData.getEntry().add(outputEntry);
                                originalTestRecord.setOutputData(outputData);
                                outputDataAdded = true;
                                break;
                            }
View Full Code Here

                    for (TestMethod testMethod : inputTestData.getTestMethod()) {
                        List<TestRecord> originalTestRecords = testMethod.getTestRecord();
                        for (TestRecord originalTestRecord : originalTestRecords) {
                            if (originalTestRecord.getId().equals(testRecord.get(RECORD_POSITION))) {
                                OutputData outputData = new OutputData();
                                Entry outputEntry = new Entry();
                                outputEntry.setKey(ACTUAL_RESULT);
                                outputEntry.setValue(testRecord.get(ACTUAL_RESULT).toString());
                                Entry durationEntry = new Entry();
                                durationEntry.setKey(DURATION);
                                durationEntry.setValue(testRecord.get(DURATION).toString());
                                outputData.getEntry().add(outputEntry);
                                outputData.getEntry().add(durationEntry);
                                if(testRecord.get(TEST_STATUS) != null){
                                    Entry statusEntry = new Entry();
                                    statusEntry.setKey(TEST_STATUS);
                                    statusEntry.setValue(testRecord.get(TEST_STATUS).toString());
                                    outputData.getEntry().add(statusEntry);
                                }
                               
                               
                                originalTestRecord.setOutputData(outputData);
                                outputDataAdded = true;
                                break;
                            }
                        }
                        if (outputDataAdded) {
                            break;
                        }
                    }
                }else{
                    //Method did not return any data. So only write the duration as output
                    for (TestMethod testMethod : inputTestData.getTestMethod()) {
                        List<TestRecord> originalTestRecords = testMethod.getTestRecord();
                        for (TestRecord originalTestRecord : originalTestRecords) {
                            if (originalTestRecord.getId().equals(testRecord.get(RECORD_POSITION))) {
                                OutputData outputData = new OutputData();
                                Entry durationEntry = new Entry();
                                durationEntry.setKey(DURATION);
                                durationEntry.setValue(testRecord.get(DURATION).toString());
                                outputData.getEntry().add(durationEntry);
                                originalTestRecord.setOutputData(outputData);
                                outputDataAdded = true;
                                break;
                            }
View Full Code Here

TOP

Related Classes of org.apache.commons.compress.archivers.zip.ZipFile$Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.