Esempio n. 1
0
 private Map<Album, Map<ImageType, Resource>> collectAlbumTargets(
     Library library, final ResourceLocator resourceLocator, Collection<Album> changedAlbums) {
   Map<Album, Map<ImageType, Resource>> result = new HashMap<>();
   for (Album album : library.getAlbums()) {
     Resource artworkAssetResource = album.artworkAssetResource();
     if (artworkAssetResource != null) {
       Map<ImageType, Resource> targets = new HashMap<ImageType, Resource>();
       for (ImageType type : ImageType.values()) {
         String imagePath = resourceLocator.getAlbumImagePath(album, type);
         if (imagePath != null) {
           Resource resource = resourceLocator.getResource(imagePath);
           try {
             if (changedAlbums.contains(album) || !resource.exists()) {
               resource.getParent().mkdirs();
               targets.put(type, resource);
             }
           } catch (IOException e) {
             LOGGER.warning("Could not write image file: " + resource.getPath().toAbsolutePath());
           }
         }
       }
       if (!targets.isEmpty()) {
         result.put(album, targets);
       }
     }
   }
   return result;
 }
 /** Tries each {@link ResourceLocator} in order, the first to return non-null wins. */
 @Override
 public InputStream findResource(URI systemId) {
   for (final ResourceLocator resourceLocator : resourceLocators) {
     logger.trace("Trying {} using ResourceLocator {}", systemId, resourceLocator);
     final InputStream result = resourceLocator.findResource(systemId);
     if (result != null) {
       logger.trace("Success with ResourceLocator {}", resourceLocator);
       return result;
     }
     logger.trace("No success with ResourceLocator {}", resourceLocator);
   }
   return null;
 }
Esempio n. 3
0
 public static void reloadVRMaps() {
   VRMap newVRMap = null;
   Hashtable<String, VRMap> newPrivVRMaps = new Hashtable<String, VRMap>();
   List<String> list = ResourceLocator.findResources(VRMap.class);
   for (String s : list) {
     VRMap m = (VRMap) ResourceLocator.loadResource(s);
     if (m.getPrivateCreator() == null) {
       newVRMap = m;
     } else {
       newPrivVRMaps.put(m.getPrivateCreator(), m);
     }
   }
   VRMap.vrMap = newVRMap;
   VRMap.privVRMaps = newPrivVRMaps;
 }
Esempio n. 4
0
 public static void loadVRMap(String resourceName) {
   VRMap m = (VRMap) ResourceLocator.loadResource(resourceName);
   if (m.getPrivateCreator() == null) {
     VRMap.vrMap = m;
   } else {
     VRMap.privVRMaps.put(m.getPrivateCreator(), m);
   }
 }
  public LookAuroraHelper(HttpSession session) {
    super(session);

    delegatedNewsService = DelegatedNewsService.get();

    messages =
        ResourceLocator.getLocalizationBundle(
            "org.silverpeas.looks.aurora.multilang.lookBundle",
            getMainSessionController().getFavoriteLanguage());
  }
Esempio n. 6
0
 public static void main(String args[]) {
   if (args.length < 2) {
     System.out.println(USAGE);
     System.exit(1);
   }
   VRMap vrMap = new VRMap(2300);
   try {
     vrMap.loadXML(new File(args[0]));
     if (args.length > 2) {
       ResourceLocator.createResource(args[1], vrMap, new File(args[2]));
       System.out.println("Create VRMap Resource  - " + args[2]);
     } else {
       ResourceLocator.serializeTo(vrMap, new File(args[1]));
       System.out.println("Serialize VRMap to - " + args[1]);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 7
0
  public static ResourceSource locateResource(final String resourceType, String resourceName) {
    if (resourceName == null) {
      return null;
    }

    try {
      resourceName = URLDecoder.decode(resourceName, "UTF-8");
    } catch (final UnsupportedEncodingException ex) {
      ex.printStackTrace();
    }

    synchronized (_locatorMap) {
      final List<ResourceLocator> bases = _locatorMap.get(resourceType);
      if (bases != null) {
        for (int i = bases.size(); --i >= 0; ) {
          final ResourceLocator loc = bases.get(i);
          final ResourceSource rVal = loc.locateResource(resourceName);
          if (rVal != null) {
            return rVal;
          }
        }
      }
      // last resort...
      try {
        final URL u =
            ResourceLocatorTool.getClassPathResource(ResourceLocatorTool.class, resourceName);
        if (u != null) {
          return new URLResourceSource(u);
        }
      } catch (final Exception e) {
        logger.logp(
            Level.WARNING,
            ResourceLocatorTool.class.getName(),
            "locateResource(String, String)",
            e.getMessage(),
            e);
      }

      logger.warning("Unable to locate: " + resourceName);
      return null;
    }
  }
Esempio n. 8
0
 public List<URL> getResources(String name) {
   return resourceLocator.getResources(name);
 }
Esempio n. 9
0
 public URL getResourceAsURL(String name) {
   return resourceLocator.getResourceAsURL(name);
 }
Esempio n. 10
0
 public InputStream getResourceAsStream(String name) {
   return resourceLocator.getResourceAsStream(name);
 }
Esempio n. 11
0
 public FileResource(String relativePathName) {
   super(ResourceLocator.locateFile(relativePathName).getAbsolutePath());
   internalPath = relativePathName;
 }