Tabnine Logo
Resource.name
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: geoserver/geoserver

@Override
public String name() {
  return delegate.name();
}
origin: geoserver/geoserver

@Override
public String getFilename() {
  return resource.name();
}
origin: geoserver/geoserver

  public String parentDirectoryName() {
    return parentDirectory.name();
  }
}
origin: geoserver/geoserver

  @Override
  public boolean accept(Resource obj) {
    return extensions.contains(
        obj.name().substring(obj.name().lastIndexOf(".") + 1).toUpperCase());
  }
}
origin: geoserver/geoserver

/**
 * Some config directories in GeoServer are used to store workspace specific configurations,
 * identify them so that we don't log complaints about their existence
 *
 * @param f
 */
private boolean isConfigDirectory(Resource dir) {
  String name = dir.name();
  boolean result = "styles".equals(name) || "layergroups".equals(name);
  return result;
}
origin: geoserver/geoserver

/**
 * Test if the file or directory behind the resource is hidden. For file system based resources,
 * the platform-dependent hidden property is used. For other resource implementations, filenames
 * starting with a "." are considered hidden, irrespective of the platform.
 *
 * @see File#isHidden()
 * @param resource Resource indicated
 * @return true If resource is hidden
 */
public static boolean isHidden(Resource resource) {
  if (resource instanceof SerializableResourceWrapper) {
    resource = ((SerializableResourceWrapper) resource).delegate;
  }
  if (resource instanceof FileSystemResourceStore.FileSystemResource
      || resource instanceof Files.ResourceAdaptor) {
    // this is a file based resource, just check the file
    return find(resource).isHidden();
  } else {
    // not a file system based resource, no point in caching
    // we only support linux style hidden file.
    return resource.name().startsWith(".");
  }
}
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

public LockFile(Resource file) throws IOException {
  lockFileTarget = file;
  if (!Resources.exists(file)) {
    throw new IOException("Cannot lock a not existing file: " + file.path());
  }
  lockFile = file.parent().get(lockFileTarget.name() + ".lock");
  Runtime.getRuntime()
      .addShutdownHook(
          new Thread(
              new Runnable() { // remove on shutdown
                @Override
                public void run() {
                  lockFile.delete();
                }
              }));
}
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

private void renameStyle(StyleInfo s, String newName) throws IOException {
  // rename style definition file
  Resource style = dd.style(s);
  StyleHandler format = Styles.handler(s.getFormat());
  Resource target = uniqueResource(style, newName, format.getFileExtension());
  renameRes(style, target.name());
  s.setFilename(target.name());
  // rename generated sld if appropriate
  if (!SLDHandler.FORMAT.equals(format.getFormat())) {
    Resource sld = style.parent().get(FilenameUtils.getBaseName(style.name()) + ".sld");
    if (sld.getType() == Type.RESOURCE) {
      LOGGER.fine("Renaming style resource " + s.getName() + " to " + newName);
      Resource generated = uniqueResource(sld, newName, "sld");
      renameRes(sld, generated.name());
    }
  }
}
origin: geoserver/geoserver

private void moveResToDir(Resource r, Resource newDir) {
  rl.move(r.path(), newDir.get(r.name()).path());
}
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

@Theory
public void theoryNameIsEndOfPath(String path) throws Exception {
  Resource res = getResource(path);
  List<String> elements = Paths.names(path);
  String lastElement = elements.get(elements.size() - 1);
  String result = res.name();
  assertThat(result, equalTo(lastElement));
}
origin: geoserver/geoserver

@Theory
public void theoryHaveName(String path) throws Exception {
  Resource res = getResource(path);
  String result = res.name();
  assertThat(result, notNullValue());
}
origin: geoserver/geoserver

private void removeStyle(StyleInfo s) throws IOException {
  Resource sld = dd.style(s);
  if (Resources.exists(sld)) {
    Resource sldBackup = dd.get(sld.path() + ".bak");
    int i = 1;
    while (Resources.exists(sldBackup)) {
      sldBackup = dd.get(sld.path() + ".bak." + i++);
    }
    LOGGER.fine("Removing the SLD as well but making backup " + sldBackup.name());
    sld.renameTo(sldBackup);
  }
}
origin: geoserver/geoserver

void loadStyles(Resource styles, Catalog catalog, XStreamPersister xp) throws IOException {
  Filter<Resource> styleFilter =
      r -> XML_FILTER.accept(r) && !Resources.exists(styles.get(r.name() + ".xml"));
  try (AsynchResourceIterator<byte[]> it =
      new AsynchResourceIterator<>(styles, styleFilter, r -> r.getContents())) {
    while (it.hasNext()) {
      try {
        StyleInfo s = depersist(xp, it.next(), StyleInfo.class);
        catalog.add(s);
        if (LOGGER.isLoggable(Level.INFO)) {
          LOGGER.info("Loaded style '" + s.getName() + "'");
        }
      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failed to load style", e);
      }
    }
  }
}
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());
  }
}
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 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);
}
org.geoserver.platform.resourceResourcename

Javadoc

Name of the resource denoted by #path() . This is the last name in the path name sequence corresponding to File#getName().

Popular methods of Resource

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

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • setScale (BigDecimal)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JLabel (javax.swing)
  • JList (javax.swing)
  • CodeWhisperer alternatives
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