congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Resource.out
Code IndexAdd Tabnine to your IDE (free)

How to use
out
method
in
org.geoserver.platform.resource.Resource

Best Java code snippets using org.geoserver.platform.resource.Resource.out (Showing top 20 results out of 315)

origin: geoserver/geoserver

@Override
public OutputStream out() {
  return delegate.out();
}
origin: geoserver/geoserver

/**
 * Write the contents of a stream into a resource
 *
 * @param data data to write
 * @param destination resource to write to
 * @throws IOException If data could not be copied to destination
 */
public static void copy(InputStream data, Resource destination) throws IOException {
  try (OutputStream out = destination.out()) {
    IOUtils.copy(data, out);
  }
}
origin: geoserver/geoserver

  /**
   * Writes a resource contents as a byte array. Usage is suggested only if the resource is known
   * to be small (e.g. a configuration file).
   *
   * @param byteArray
   * @throws IOException
   */
  default void setContents(byte[] byteArray) throws IOException {
    try (OutputStream os = out()) {
      IOUtils.write(byteArray, os);
    }
  }
}
origin: geoserver/geoserver

/**
 * Safe write on styleFile the passed inputStream
 *
 * @param in the new stream to write to styleFile
 * @param styleFile file to update
 * @throws IOException
 */
public static void writeStyle(final InputStream in, final Resource styleFile)
    throws IOException {
  try (BufferedOutputStream out = new BufferedOutputStream(styleFile.out())) {
    IOUtils.copy(in, out);
    out.flush();
  }
}
origin: geoserver/geoserver

/** Helper method which uses xstream to persist an object as xml on disk. */
void persist(XStreamPersister xp, Object obj, Resource f) throws Exception {
  BufferedOutputStream out = new BufferedOutputStream(f.out());
  xp.save(obj, out);
  out.flush();
  out.close();
}
origin: geoserver/geoserver

@Override
protected void loadProperties(Properties props) throws IOException {
  try {
    super.loadProperties(props);
  } catch (FileNotFoundException e) {
    // location was not found, create
    if (configFile != null && copyOutTemplate) {
      try (OutputStream fout = configFile.out()) {
        props.store(fout, comments);
        fout.flush();
      }
    }
  }
}
origin: geoserver/geoserver

  /**
   * Performs serialization with an {@link XStreamPersister} in a safe manner in which a temp file
   * is used for the serialization so that the true destination file is not partially written in
   * the case of an error.
   *
   * @param r The resource to write to, only modified if the temp file serialization was error
   *     free.
   * @param obj The object to serialize.
   * @param xp The persister.
   */
  public static void xStreamPersist(Resource r, Object obj, XStreamPersister xp)
      throws IOException {

    try (OutputStream out = r.out()) {
      xp.save(obj, out);
      out.flush();
    }
  }
}
origin: geoserver/geoserver

static OutputStream output(URL url, Resource configDir) throws IOException {
  // check for file url
  if ("file".equalsIgnoreCase(url.getProtocol())) {
    File f = URLs.urlToFile(url);
    if (!f.isAbsolute()) {
      // make relative to config dir
      return configDir.get(f.getPath()).out();
    } else {
      return new FileOutputStream(f);
    }
  } else {
    URLConnection cx = url.openConnection();
    cx.setDoOutput(true);
    return cx.getOutputStream();
  }
}
origin: geoserver/geoserver

void saveMasterPasswordDigest(String masterPasswdDigest) throws IOException {
  OutputStream fout = security().get(MASTER_PASSWD_DIGEST_FILENAME).out();
  try {
    IOUtils.write(masterPasswdDigest, fout);
  } finally {
    fout.close();
  }
}
origin: geoserver/geoserver

private void writeCurrentVersion() throws IOException {
  Resource security = security();
  security.dir();
  Resource properties = security.get(VERSION_PROPERTIES);
  Properties p = new Properties();
  p.put(VERSION, CURR_VERSION.toString());
  try (OutputStream os = properties.out()) {
    p.store(
        os,
        "Current version of the security directory. Do not remove or alter this file");
  }
}
origin: geoserver/geoserver

  private void copyResToDir(Resource r, Resource newDir) throws IOException {
    Resource newR = newDir.get(r.name());
    try (InputStream in = r.in();
        OutputStream out = newR.out()) {
      IOUtils.copy(in, out);
    }
  }
}
origin: geoserver/geoserver

@Override
public void storeKeyStore() throws IOException {
  // store away the keystore
  assertActivatedKeyStore();
  try (OutputStream fos = getResource().out()) {
    char[] passwd = securityManager.getMasterPassword();
    try {
      ks.store(fos, passwd);
    } catch (Exception e) {
      throw new IOException(e);
    } finally {
      securityManager.disposePassword(passwd);
    }
  }
}
origin: geoserver/geoserver

@Theory
public void theoryDoubleClose(String path) throws Exception {
  final Resource res = getResource(path);
  assumeThat(res, is(resource()));
  OutputStream os = res.out();
  os.close();
  os.close();
}
origin: geoserver/geoserver

public final void save(T service, GeoServer gs, Resource directory) throws Exception {
  String filename = getFilename();
  Resource resource =
      directory == null ? resourceLoader.get(filename) : directory.get(filename);
  // using resource output stream makes sure we write on a temp file and them move
  try (OutputStream out = resource.out()) {
    XStreamPersister xp = xpf.createXMLPersister();
    initXStreamPersister(xp, gs);
    xp.save(service, out);
  }
}
origin: geoserver/geoserver

@Theory
public void theoryNonDirectoriesHaveFileWithSameContents(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, not(directory()));
  byte[] test = {42, 29, 32, 120, 69, 0, 1};
  try (OutputStream ostream = res.out()) {
    ostream.write(test);
  }
  byte[] result = new byte[test.length];
  try (InputStream istream = new FileInputStream(res.file())) {
    istream.read(result);
    assertThat(istream.read(), is(-1));
  }
  assertThat(result, equalTo(test));
}
origin: geoserver/geoserver

@Theory
public void theoryLeavesHaveOstream(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(resource()));
  try (OutputStream result = res.out()) {
    assertThat(result, notNullValue());
  }
}
origin: geoserver/geoserver

@Theory
public void theoryNonDirectoriesPersistData(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, not(directory()));
  byte[] test = {42, 29, 32, 120, 69, 0, 1};
  try (OutputStream ostream = res.out()) {
    ostream.write(test);
  }
  byte[] result = new byte[test.length];
  try (InputStream istream = res.in()) {
    istream.read(result);
    assertThat(istream.read(), is(-1));
  }
  assertThat(result, equalTo(test));
}
origin: geoserver/geoserver

@Theory
public void theoryDirectoriesHaveNoOstream(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  exception.expect(IllegalStateException.class);
  res.out().close();
}
origin: geoserver/geoserver

@Theory
public void theoryUndefinedHaveOstreamAndBecomeResource(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(undefined()));
  try (OutputStream result = res.out()) {
    assertThat(result, notNullValue());
    assertThat(res, is(resource()));
  }
}
origin: geoserver/geoserver

@Override
protected void onSetUp(SystemTestData testData) throws Exception {
  super.onSetUp(testData);
  LayerInfo li = getCatalog().getLayerByName(getLayerId(SystemTestData.BUILDINGS));
  Resource resource = getDataDirectory().config(li);
  Document dom;
  try (InputStream is = resource.in()) {
    dom = dom(resource.in());
  }
  Element defaultStyle = (Element) dom.getElementsByTagName("defaultStyle").item(0);
  Element defaultStyleId = (Element) defaultStyle.getElementsByTagName("id").item(0);
  defaultStyleId.setTextContent("danglingReference");
  try (OutputStream os = resource.out()) {
    print(dom, os);
  }
  getGeoServer().reload();
}
org.geoserver.platform.resourceResourceout

Javadoc

Steam access to resource contents.

Popular methods of Resource

  • getType
  • in
  • get
  • dir
  • file
  • path
  • delete
  • name
  • list
  • lastmodified
  • parent
  • addListener
  • parent,
  • addListener,
  • renameTo,
  • getContents,
  • removeListener,
  • load,
  • lock,
  • save,
  • setContents

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now