congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Resource.list
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: geoserver/geoserver

@Override
public List<Resource> list() {
  List<Resource> children = new ArrayList<Resource>();
  for (Resource child : delegate.list()) {
    children.add(new SerializableResourceWrapper(child));
  }
  return children;
}
origin: geoserver/geoserver

/**
 * Returns filtered children of a directory
 *
 * @param dir parent directory
 * @param filter the filter that selects children
 * @param recursive searches recursively
 * @return filtered list
 */
public static List<Resource> list(Resource dir, Filter<Resource> filter, boolean recursive) {
  List<Resource> res = new ArrayList<Resource>();
  for (Resource child : dir.list()) {
    if (filter.accept(child)) {
      res.add(child);
    }
    if (recursive && child.getType() == Type.DIRECTORY) {
      res.addAll(list(child, filter, true));
    }
  }
  return res;
}
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

/**
 * Search for resources using pattern and last modified time.
 *
 * @param resource Resource indicated
 * @param lastModified time stamp to search from
 * @return list of modified resources
 */
public static List<Resource> search(Resource resource, long lastModified) {
  if (resource.getType() == Type.DIRECTORY) {
    ArrayList<Resource> results = new ArrayList<Resource>();
    for (Resource child : resource.list()) {
      switch (child.getType()) {
        case RESOURCE:
          if (child.lastmodified() > lastModified) {
            results.add(child);
          }
          break;
        default:
          break;
      }
    }
    return results;
  }
  return Collections.emptyList();
}
origin: geoserver/geoserver

root.list()
    .parallelStream()
    .filter(r -> filter.accept(r))
origin: geoserver/geoserver

@Theory
public void theoryLeavesHaveEmptyListOfChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(resource()));
  Collection<Resource> result = res.list();
  assertThat(result, empty());
}
origin: geoserver/geoserver

@Theory
public void theoryUndefinedHaveEmptyListOfChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(undefined()));
  Collection<Resource> result = res.list();
  assertThat(result, empty());
}
origin: geoserver/geoserver

@Theory
public void theoryDirectoriesHaveChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  Collection<Resource> result = res.list();
  assertThat(result, notNullValue());
}
origin: geoserver/geoserver

@Theory
public void theoryChildrenKnowTheirParents(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  Collection<Resource> children = res.list();
  assumeThat(children, not(empty())); // Make sure this resource has children
  for (Resource child : children) {
    Resource parent = child.parent();
    assertThat(parent, equalTo(res));
  }
}
origin: geoserver/geoserver

/**
 * Write the contents of a resource into another resource. Also supports directories
 * (recursively).
 *
 * @param data resource to read
 * @param destination resource to write to
 * @throws IOException If data could not be copied to destination
 */
public static void copy(Resource data, Resource destination) throws IOException {
  if (data.getType() == Type.DIRECTORY) {
    for (Resource child : data.list()) {
      copy(child, destination.get(child.name()));
    }
  } else {
    try (InputStream in = data.in()) {
      copy(in, destination);
    }
  }
}
origin: geoserver/geoserver

@Theory
public void theoryParentsKnowTheirChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  Resource parent = res.parent();
  assumeThat(path, parent, notNullValue()); // Make sure this resource has a parent
  Collection<Resource> result = parent.list();
  assertThat(path, result, hasItem(res)); // this assumed equals was written!
}
origin: geoserver/geoserver

@Theory
public void theoryRecursiveDelete(String path) throws Exception {
  final Resource res = getResource(path);
  assumeThat(res, is(directory()));
  assumeThat(res, is(directory()));
  Collection<Resource> result = res.list();
  assumeThat(result.size(), greaterThan(0));
  assertTrue(res.delete());
}
origin: geoserver/geoserver

@Theory
public void theoryAddingFileToDirectoryAddsResource(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  File dir = res.dir();
  File file = new File(dir, "newFileCreatedDirectly");
  assumeTrue(file.createNewFile());
  Resource child = getResource(Paths.path(res.path(), "newFileCreatedDirectly"));
  Collection<Resource> children = res.list();
  assertThat(child, is(defined()));
  assertThat(children, hasItem(child));
}
origin: geoserver/geoserver

@Theory
public void theoryDirectoriesHaveFileWithSameNamedChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  File dir = res.dir();
  Collection<Resource> resChildren = res.list();
  String[] fileChildrenNames = dir.list();
  String[] resChildrenNames = new String[resChildren.size()];
  int i = 0;
  for (Resource child : resChildren) {
    resChildrenNames[i] = child.name();
    i++;
  }
  assertThat(fileChildrenNames, arrayContainingInAnyOrder(resChildrenNames));
}
origin: geoserver/geoserver

@Test
public void testReloadDefaultStyles() throws Exception {
  // clear up all "point" styles
  final Resource styles = getDataDirectory().getStyles();
  styles.list()
      .stream()
      .filter(r -> r.getType() == Resource.Type.RESOURCE && r.name().contains("point"))
      .forEach(r -> r.delete());
  // reload
  getGeoServer().reload();
  // check the default point style has been re-created
  final StyleInfo point = getCatalog().getStyleByName("point");
  assertNotNull(point);
}
origin: geoserver/geoserver

.list()
.parallelStream()
.filter(r -> Resources.DirectoryFilter.INSTANCE.accept(r))
origin: geoserver/geoserver

Map<String, Map<String, Object>> dataStores = creader.dataStores();
for (Resource featureTypeDir : featureTypesDir.list()) {
  if (featureTypeDir.getType() != Type.DIRECTORY) {
    continue;
  if (destFeatureTypeDir != null) {
    for (Resource file : featureTypeDir.list()) {
      if (file.getType() == Type.RESOURCE && !featureTypeInfo.equals(file)) {
        IOUtils.copy(file.in(), destFeatureTypeDir.get(file.name()).out());
origin: geoserver/geoserver

for (Resource dir : workspaces.list()) {
  if (dir.getType() != Type.DIRECTORY) continue;
for (Resource dir : workspaces.list()) {
  if (dir.getType() != Type.DIRECTORY) continue;
origin: org.geoserver/gs-platform

@Theory
public void theoryDirectoriesHaveChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  Collection<Resource> result = res.list();
  assertThat(result, notNullValue());
}
origin: org.geoserver/gs-platform

@Theory
public void theoryParentsKnowTheirChildren(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, is(directory()));
  Resource parent = res.parent();
  assumeThat(path, parent, notNullValue()); // Make sure this resource has a parent
  Collection<Resource> result = parent.list();
  assertThat(path, result, hasItem(res)); // this assumed equals was written!
}
org.geoserver.platform.resourceResourcelist

Javadoc

List of directory contents.

The listed files exist (and may be DIRECTORY or RESOURCE items).

Popular methods of Resource

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

Popular in Java

  • Making http requests using okhttp
  • setRequestProperty (URLConnection)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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