Codota Logo
Resource.get
Code IndexAdd Codota to your IDE (free)

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

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

  • Common ways to obtain Resource
private void myMethod () {
Resource r =
  • Codota IconGeoServerResourceLoader geoServerResourceLoader;String path;geoServerResourceLoader.get(path)
  • Codota IconResourceStore resourceStore;String path;resourceStore.get(path)
  • Codota IconFile file;Files.asResource(file)
  • Smart code suggestions by Codota
}
origin: geoserver/geoserver

SortedSet<String> listFiles(Resource dir) {
  SortedSet<String> result = new TreeSet<String>();
  List<Resource> dirs = dir.list();
  for (Resource d : dirs) {
    if (d.getType() == Type.DIRECTORY
        && d.get(CONFIG_FILENAME).getType() == Type.RESOURCE) {
      result.add(d.name());
    }
  }
  return result;
}
origin: geoserver/geoserver

/**
 * Write the contents of a stream to a new Resource inside a directory
 *
 * @param data data to write
 * @param directory parent directory to create the resource in
 * @param filename file name of the new resource
 * @throws IOException If data could not be copied into indicated location
 */
public static void copy(InputStream data, Resource directory, String filename)
    throws IOException {
  copy(data, directory.get(filename));
}
origin: geoserver/geoserver

public static Resource createRandom(String prefix, String suffix, Resource dir)
    throws IOException {
  // Use only the file name from the supplied prefix
  prefix = (new File(prefix)).getName();
  Resource res;
  do {
    UUID uuid = UUID.randomUUID();
    String name = prefix + uuid + suffix;
    res = dir.get(name);
  } while (exists(res));
  return res;
}
origin: geoserver/geoserver

/** loads the named entity config from persistence */
public C loadConfig(String name, MigrationHelper migrationHelper) throws IOException {
  Resource dir = getRoot().get(name);
  if (dir.getType() != Type.DIRECTORY) {
    return null;
  }
  XStreamPersister xp = persister();
  if (migrationHelper != null) {
    migrationHelper.migrationPersister(xp);
  }
  return (C) loadConfigFile(dir, xp);
}
origin: geoserver/geoserver

@Override
public Resource getResource() {
  if (keyStoreResource == null) {
    keyStoreResource = securityManager.security().get(DEFAULT_FILE_NAME);
  }
  return keyStoreResource;
}
origin: geoserver/geoserver

/** saves a config file to the specified directly using the specified xstream persister */
void saveConfigFile(
    SecurityConfig config, Resource directory, String filename, XStreamPersister xp)
    throws IOException {
  xStreamPersist(directory.get(filename), config, xp);
}
origin: geoserver/geoserver

@Override
public org.springframework.core.io.Resource createRelative(String relativePath)
    throws IOException {
  return new SpringResourceAdaptor(resource.get(relativePath));
}
origin: geoserver/geoserver

/**
 * Write the contents of a File to a new Resource with the same name inside a directory
 *
 * @param data data to write
 * @param directory parent directory to create the resource in
 * @throws IOException If file could not be copied into directory
 */
public static void copy(File data, Resource directory) throws IOException {
  String filename = data.getName();
  try (InputStream in = new FileInputStream(data)) {
    copy(in, directory.get(filename));
  }
}
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

/** removes the user group service config from persistence */
public void removeConfig(String name) throws IOException {
  getRoot().get(name).delete();
}
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

/** reads a config file from the specified directly using the specified xstream persister */
SecurityConfig loadConfigFile(Resource directory, String filename, XStreamPersister xp)
    throws IOException {
  InputStream fin = directory.get(filename).in();
  try {
    return xp.load(fin, SecurityConfig.class).clone(true);
  } finally {
    fin.close();
  }
}
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

/** The root configuration for the role service. */
public Resource getConfigRoot() throws IOException {
  return getSecurityManager().role().get(getName());
}
origin: geoserver/geoserver

/** Saves master password config out directly, not during a password change. */
public void saveMasterPasswordConfig(MasterPasswordConfig config) throws IOException {
  xStreamPersist(security().get(MASTER_PASSWD_CONFIG_FILENAME), config, globalPersister());
  this.masterPasswordConfig = new MasterPasswordConfig(config);
}
origin: geoserver/geoserver

public void handleServiceRemove(ServiceInfo service) {
  XStreamServiceLoader loader = findServiceLoader(service);
  try {
    Resource dir =
        service.getWorkspace() != null
            ? dir(service.getWorkspace())
            : resourceLoader.get(Paths.BASE);
    dir.get(loader.getFilename()).delete();
  } catch (Throwable t) {
    throw new RuntimeException(t);
  }
}
origin: geoserver/geoserver

private void renameRes(Resource r, String newName) {
  try {
    rl.move(r.path(), r.parent().get(newName).path());
  } catch (Exception e) {
    throw new CatalogException(e);
  }
}
origin: geoserver/geoserver

private void moveResToDir(Resource r, Resource newDir) {
  try {
    rl.move(r.path(), newDir.get(r.name()).path());
  } catch (Exception e) {
    throw new CatalogException(e);
  }
}
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

  @Test
  public void resourcesTest() throws IOException {
    Resource source = getResource();

    Resource directory = getDirectory();

    Resources.copy(source.file(), directory);

    Resource target = directory.get(source.name());

    assertTrue(Resources.exists(target));
    assertEquals(target.name(), source.name());
  }
}
org.geoserver.platform.resourceResourceget

Javadoc

Path based resource access which can be used to access #list() contents or create a new undefined resource.

The returned Resource acts as a handle, and may be UNDEFINED. In general Resources are created in a lazy fashion when used for the first time.

This method is used to access directory contents, relative paths such as ".." and "." are not supported.

Popular methods of Resource

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

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • String (java.lang)
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now