org.geoserver.util.IOUtils.decompress()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.geoserver.util.IOUtils.decompress()方法的一些代码示例,展示了IOUtils.decompress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.decompress()方法的具体详情如下:
包路径:org.geoserver.util.IOUtils
类名称:IOUtils
方法名:decompress

IOUtils.decompress介绍

暂无

代码示例

代码示例来源:origin: geoserver/geoserver

/**
   * Unzips a SLD package to a temporal folder, returning the SLD file path.
   *
   * @param input
   * @throws IOException
   */
  private File unzipSldPackage(Object input) throws IOException {
    File myTempDir = Files.createTempDir();

    org.geoserver.util.IOUtils.decompress((InputStream) input, myTempDir);

    File[] files =
        myTempDir.listFiles(
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(".sld");
              }
            });

    if (files.length != 1) {
      throw new IOException("No SLD file");
    }

    return files[0];
  }
}

代码示例来源:origin: geoserver/geoserver

@Override
  public void setUpSecurity() throws IOException {
    File secDir = new File(getDataDirectoryRoot(), "security");
    IOUtils.decompress(
        Security_2_2_TestData.class.getResourceAsStream("security-2.2.zip"), secDir);
  }
}

代码示例来源:origin: geoserver/geoserver

public void setUpSecurity() throws IOException {
  File secDir = new File(getDataDirectoryRoot(), "security");
  IOUtils.decompress(SystemTestData.class.getResourceAsStream("security.zip"), secDir);
  String javaVendor = System.getProperty("java.vendor");
  if (javaVendor.contains("IBM")) {
    IOUtils.copy(
        new File(secDir, "geoserver.jceks.ibm"), new File(secDir, "geoserver.jceks"));
  } else {
    IOUtils.copy(
        new File(secDir, "geoserver.jceks.default"),
        new File(secDir, "geoserver.jceks"));
  }
}

代码示例来源:origin: geoserver/geoserver

@Test
public void testZipUnzip() throws IOException {
  Path p1 = temp.newFolder("d1").toPath();
  p1.resolve("foo/bar").toFile().mkdirs();
  Files.touch(p1.resolve("foo/bar/bar.txt").toFile());
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  ZipOutputStream zout = new ZipOutputStream(bout);
  IOUtils.zipDirectory(p1.toFile(), zout, null);
  Path p2 = temp.newFolder("d2").toPath();
  p2.toFile().mkdirs();
  ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
  IOUtils.decompress(bin, p2.toFile());
  assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists());
}

代码示例来源:origin: geoserver/geoserver

IOUtils.decompress(compressedFile, f);
final File srcDir = new File(f, name.getLocalPart());
srcDir.mkdir();

代码示例来源:origin: geoserver/geoserver

@Test
public void testDecompressStreamBadEntryName() throws IOException {
  File destDir = temp.newFolder("d3").toPath().toFile();
  destDir.mkdirs();
  try (InputStream input = ZipTestUtil.getZipSlipInput()) {
    IOUtils.decompress(input, destDir);
    fail("Expected decompression to fail");
  } catch (IOException e) {
    assertThat(e.getMessage(), startsWith("Entry is outside of the target directory"));
  }
}

代码示例来源:origin: geoserver/geoserver

@Test
  public void testDecompressFileBadEntryName() throws IOException {
    File destDir = temp.newFolder("d4").toPath().toFile();
    destDir.mkdirs();
    File input = ZipTestUtil.initZipSlipFile(temp.newFile("d4.zip"));
    try {
      IOUtils.decompress(input, destDir);
      fail("Expected decompression to fail");
    } catch (IOException e) {
      assertThat(e.getMessage(), startsWith("Entry is outside of the target directory"));
    }
  }
}

代码示例来源:origin: geoserver/geoserver

/** Keys for overriding default layer properties */
public static class StyleProperty<T> {
  T get(Map<StyleProperty, Object> map, T def) {
    return map != null && map.containsKey(this) ? (T) map.get(this) : def;
  }
  public static StyleProperty<String> FORMAT = new StyleProperty<String>();
  public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>();
  public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>();
}

代码示例来源:origin: org.geoserver/gs-rest

/**
   * Unzips a InputStream to a directory
   *
   * @param in
   * @param outputDirectory
   * @throws IOException
   */
  public static void unzipInputStream(InputStream in, File outputDirectory) throws IOException {
    org.geoserver.util.IOUtils.decompress(in, outputDirectory);
  }
}

代码示例来源:origin: org.geoserver/gs-restconfig

/**
 * Extracts an input stream representing a zipped directory containing an sld file and any
 * number of image files to a temporary location on the filesystem.
 *
 * @param object The input stream containing the zipped directory
 * @return A file pointing to the (temporary) unzipped directory
 * @throws IOException if there was an error extracting the archive
 */
private File unzipSldPackage(InputStream object) throws IOException {
  File tempDir = Files.createTempDir();
  org.geoserver.util.IOUtils.decompress(object, tempDir);
  return tempDir;
}

代码示例来源:origin: org.geoserver/gs-platform

@Test
public void testZipUnzip() throws IOException {
  Path p1 = temp.newFolder("d1").toPath();
  p1.resolve("foo/bar").toFile().mkdirs();
  Files.touch(p1.resolve("foo/bar/bar.txt").toFile());
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  ZipOutputStream zout = new ZipOutputStream(bout);
  IOUtils.zipDirectory(p1.toFile(), zout, null);
  Path p2 = temp.newFolder("d2").toPath();
  p2.toFile().mkdirs();
  ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
  IOUtils.decompress(bin, p2.toFile());
  assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists());
}

代码示例来源:origin: org.geoserver/gs-platform

@Test
public void testDecompressStreamBadEntryName() throws IOException {
  File destDir = temp.newFolder("d3").toPath().toFile();
  destDir.mkdirs();
  try (InputStream input = ZipTestUtil.getZipSlipInput()) {
    IOUtils.decompress(input, destDir);
    fail("Expected decompression to fail");
  } catch (IOException e) {
    assertThat(e.getMessage(), startsWith("Entry is outside of the target directory"));
  }
}

代码示例来源:origin: org.geoserver/gs-platform

@Test
  public void testDecompressFileBadEntryName() throws IOException {
    File destDir = temp.newFolder("d4").toPath().toFile();
    destDir.mkdirs();
    File input = ZipTestUtil.initZipSlipFile(temp.newFile("d4.zip"));
    try {
      IOUtils.decompress(input, destDir);
      fail("Expected decompression to fail");
    } catch (IOException e) {
      assertThat(e.getMessage(), startsWith("Entry is outside of the target directory"));
    }
  }
}

代码示例来源:origin: org.geoserver/gs-wms

IOUtils.decompress(target, targetDir);

相关文章