Search in sources :

Example 6 with Resource

use of org.onebusaway.presentation.services.resources.Resource in project onebusaway-application-modules by camsys.

the class ResourceServiceImpl method getExternalUrlForResources.

@Override
public String getExternalUrlForResources(String resourceId, List<String> resourcePaths, Locale locale) {
    LocaleProvider localeProvider = new LocaleProviderImpl(locale);
    Resource resource = getResourceForPaths(resourceId, resourcePaths, localeProvider);
    if (resource == null) {
        _log.warn("resource not found: " + resourceId);
        return null;
    }
    if (_debug)
        refreshResource(resource);
    return resource.getExternalUrl();
}
Also used : LocaleProvider(com.opensymphony.xwork2.LocaleProvider) Resource(org.onebusaway.presentation.services.resources.Resource)

Example 7 with Resource

use of org.onebusaway.presentation.services.resources.Resource in project onebusaway-application-modules by camsys.

the class ResourceServiceImpl method getResourceForPath.

private Resource getResourceForPath(String resourcePath, LocaleProvider localeProvider, URL sourceUrl) {
    String resourcePathKey = getResourcePathAsKey(resourcePath, localeProvider);
    Resource resource = _resourceEntriesByResourcePath.get(resourcePathKey);
    if (resource == null) {
        resource = createResourceForPath(resourcePath, sourceUrl, localeProvider);
        if (resource == null)
            return null;
        Resource existingResource = _resourceEntriesByResourcePath.putIfAbsent(resourcePathKey, resource);
        if (existingResource != null)
            return existingResource;
    }
    return resource;
}
Also used : Resource(org.onebusaway.presentation.services.resources.Resource)

Example 8 with Resource

use of org.onebusaway.presentation.services.resources.Resource in project onebusaway-application-modules by camsys.

the class ResourceServiceImpl method getExternalUrlForResource.

/**
 **
 * {@link ResourceService} Interface
 ***
 */
@Override
public String getExternalUrlForResource(String resourcePath, Locale locale) {
    LocaleProvider localeProvider = new LocaleProviderImpl(locale);
    Resource resource = getResourceForPath(resourcePath, localeProvider, null);
    if (resource == null) {
        _log.warn("resource not found: " + resourcePath);
        return null;
    }
    if (_debug)
        refreshResource(resource);
    return resource.getExternalUrl();
}
Also used : LocaleProvider(com.opensymphony.xwork2.LocaleProvider) Resource(org.onebusaway.presentation.services.resources.Resource)

Aggregations

Resource (org.onebusaway.presentation.services.resources.Resource)8 LocaleProvider (com.opensymphony.xwork2.LocaleProvider)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JSONObject (org.json.JSONObject)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)1