Search in sources :

Example 11 with WOApplication

use of com.webobjects.appserver.WOApplication in project wonder-slim by undur.

the class ERXProperties method pathForResourceNamed.

/**
 * Determines the path of the specified Resource. This is done to get a
 * single entry point due to the deprecation of pathForResourceNamed
 *
 * @param fileName name of the file
 * @param frameworkName name of the framework, <code>null</code> or "app" for the application bundle
 * @param languages array of languages to get localized resource or <code>null</code>
 * @return the absolutePath method off of the file object
 */
private static String pathForResourceNamed(String fileName, String frameworkName, NSArray<String> languages) {
    String path = null;
    NSBundle bundle = "app".equals(frameworkName) ? NSBundle.mainBundle() : NSBundle.bundleForName(frameworkName);
    if (bundle != null && bundle.isJar()) {
        // FIXME: Changed log level to debug
        // This was emitting at every application startup, seemingly without purpose.
        // Since property loading seems to work fine anyway, I turned it to debug
        // and we're going to have to have a look at property loading in general later.
        log.debug("Can't get path when run as jar: {} - {}", frameworkName, fileName);
    } else {
        WOApplication application = WOApplication.application();
        if (application != null) {
            URL url = application.resourceManager().pathURLForResourceNamed(fileName, frameworkName, languages);
            if (url != null) {
                path = url.getFile();
            }
        } else if (bundle != null) {
            URL url = bundle.pathURLForResourcePath(fileName);
            if (url != null) {
                path = url.getFile();
            }
        }
    }
    return path;
}
Also used : NSBundle(com.webobjects.foundation.NSBundle) WOApplication(com.webobjects.appserver.WOApplication) URL(java.net.URL)

Aggregations

WOApplication (com.webobjects.appserver.WOApplication)11 WOResponse (com.webobjects.appserver.WOResponse)7 WOComponent (com.webobjects.appserver.WOComponent)4 WOContext (com.webobjects.appserver.WOContext)4 WOSession (com.webobjects.appserver.WOSession)3 WORequest (com.webobjects.appserver.WORequest)2 NSBundle (com.webobjects.foundation.NSBundle)2 NSDictionary (com.webobjects.foundation.NSDictionary)2 File (java.io.File)2 IOException (java.io.IOException)2 WOActionResults (com.webobjects.appserver.WOActionResults)1 WODynamicURL (com.webobjects.appserver.WODynamicURL)1 WOMultipartIterator (com.webobjects.appserver.WOMultipartIterator)1 WOStatisticsStore (com.webobjects.appserver.WOStatisticsStore)1 NSArray (com.webobjects.foundation.NSArray)1 ERXAjaxApplication (er.extensions.appserver.ajax.ERXAjaxApplication)1 ERXUnitAwareDecimalFormat (er.extensions.formatters.ERXUnitAwareDecimalFormat)1 ERXMutableURL (er.extensions.foundation.ERXMutableURL)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1