예제 #1
0
 @Override
 public Set<String> getResourcePaths(final String path) {
   final Resource resource;
   try {
     resource = deploymentInfo.getResourceManager().getResource(path);
   } catch (IOException e) {
     return null;
   }
   if (resource == null || !resource.isDirectory()) {
     return null;
   }
   final Set<String> resources = new HashSet<String>();
   for (Resource res : resource.list()) {
     File file = res.getFile();
     if (file != null) {
       File base = res.getResourceManagerRoot();
       String filePath = file.getAbsolutePath().substring(base.getAbsolutePath().length());
       filePath = filePath.replace('\\', '/'); // for windows systems
       if (file.isDirectory()) {
         filePath = filePath + "/";
       }
       resources.add(filePath);
     }
   }
   return resources;
 }
예제 #2
0
 @Override
 public URL getResource(final String path) throws MalformedURLException {
   if (!path.startsWith("/")) {
     throw UndertowServletMessages.MESSAGES.pathMustStartWithSlash(path);
   }
   Resource resource = null;
   try {
     resource = deploymentInfo.getResourceManager().getResource(path);
   } catch (IOException e) {
     return null;
   }
   if (resource == null) {
     return null;
   }
   return resource.getUrl();
 }
예제 #3
0
 @Override
 public String getRealPath(final String path) {
   if (path == null) {
     return null;
   }
   Resource resource = null;
   try {
     resource = deploymentInfo.getResourceManager().getResource(path);
   } catch (IOException e) {
     return null;
   }
   if (resource == null) {
     return null;
   }
   File file = resource.getFile();
   if (file == null) {
     return null;
   }
   return file.getAbsolutePath();
 }
예제 #4
0
 @Override
 public InputStream getResourceAsStream(final String path) {
   Resource resource = null;
   try {
     resource = deploymentInfo.getResourceManager().getResource(path);
   } catch (IOException e) {
     return null;
   }
   if (resource == null) {
     return null;
   }
   try {
     if (resource.getFile() != null) {
       return new BufferedInputStream(new FileInputStream(resource.getFile()));
     } else {
       return new BufferedInputStream(resource.getUrl().openStream());
     }
   } catch (FileNotFoundException e) {
     // should never happen, as the resource loader should return null in this case
     return null;
   } catch (IOException e) {
     return null;
   }
 }