Package com.webobjects.appserver

Examples of com.webobjects.appserver.WOResourceManager


      String s = null;

      if (t == null) {
        try {
          WOApplication app = WOApplication.application();
          WOResourceManager rm = app.resourceManager();

          TransformerFactory fac = TransformerFactory.newInstance();

          log.debug("creating template for file " + filename + " in framework " + framework);
          InputStream is = rm.inputStreamForResourceNamed(filename, framework, null);
          if (is == null) {
            log.debug("trying with framework = null");
            is = rm.inputStreamForResourceNamed(filename, null, null);
            if (is == null) {
              throw new IllegalArgumentException("inputStream is null");
            }
          }
          if (is.available() == 0) {
View Full Code Here


   *            the list of languages to use for finding components
   * @return the URL to the template (or null if there isn't one)
   */
  public static URL templateUrl(String componentName, String extension, NSArray languages) {
    String htmlPathName = componentName + ".wo/" + componentName + "." + extension;
    WOResourceManager resourceManager = WOApplication.application().resourceManager();
    URL templateUrl = pathUrlForResourceNamed(resourceManager, htmlPathName, languages);
    if (templateUrl == null) {
      // jw: hack for bundle-less builds as there is some sort of classpath problem that will
      // pick up the wrong class for WOProjectBundle, _WOProject, … that register only component's
      // .wo directories but not the containing files (.html, .wod, .woo). Thus we are assuming
View Full Code Here

    FileInputStream is = null;
    long length = 0;
    String contentType = null;
    String uri = request.uri();
    if (uri.charAt(0) == '/') {
      WOResourceManager rm = application.resourceManager();
      String documentRoot = documentRoot();
      File file = null;
      StringBuilder sb = new StringBuilder(documentRoot.length() + uri.length());
      String wodataKey = request.stringFormValueForKey("wodata");
      if(uri.startsWith("/cgi-bin") && wodataKey != null) {
        uri = wodataKey;
        if(uri.startsWith("file:")) {
          // remove file:/
          uri = uri.substring(5);
        } else {
         
        }
      } else {
        int index = uri.indexOf("/wodata=");

        if(index >= 0) {
          uri = uri.substring(index+"/wodata=".length());
        } else {
          sb.append(documentRoot);
        }
      }
     
      if (_useRequestHandlerPath) {
          try {
            WODynamicURL dynamicURL = new WODynamicURL(uri);
            String requestHandlerPath = dynamicURL.requestHandlerPath();
            if (requestHandlerPath == null || requestHandlerPath.length() == 0) {
              sb.append(uri);
            } else {
              sb.append('/');
              sb.append(requestHandlerPath);
            }
          }
          catch (Exception e) {
            throw new RuntimeException("Failed to parse URL '" + uri + "'.", e);
          }
      }
      else {
        sb.append(uri);
      }
     
      String path = sb.toString();
      try {
        path = path.replaceAll("\\?.*", "");
        if (request.userInfo() != null && !request.userInfo().containsKey("HttpServletRequest")) {
          /* PATH_INFO is already decoded by the servlet container */
          path = path.replace('+', ' ');
          path = URLDecoder.decode(path, CharEncoding.UTF_8);
        }
        file = new File(path);
        length = file.length();
        is = new FileInputStream(file);
       
        contentType = rm.contentTypeForResourceNamed(path);
        log.debug("Reading file '" + file + "' for uri: " + uri);
      } catch (IOException ex) {
        if (!uri.toLowerCase().endsWith("/favicon.ico")) {
          log.info("Unable to get contents of file '" + file + "' for uri: " + uri);
        }
View Full Code Here

        String url;
        if (fileName.indexOf("://") != -1 || fileName.startsWith("/")) {
          url = fileName;
        }
        else {
          WOResourceManager rm = WOApplication.application().resourceManager();
          NSArray languages = null;
          if (context.hasSession()) {
            languages = context.session().languages();
          }
          url = rm.urlForResourceNamed(fileName, framework, languages, context.request());
          boolean generateCompleteResourceURLs = ERXResourceManager._shouldGenerateCompleteResourceURL(context);
          boolean secureAllResources = ERXProperties.booleanForKey(ERXResponseRewriter.SECURE_RESOURCES_KEY) && !ERXRequest.isRequestSecure(context.request());
          if (generateCompleteResourceURLs || secureAllResources) {
            url = ERXResourceManager._completeURLForResource(url, secureAllResources ? Boolean.TRUE : null, context);
          }
View Full Code Here

      if(val != null) {
        framework = val.toString();
      }
    }
   
    WOResourceManager rs = WOApplication.application().resourceManager();
    if (!href.startsWith("http://") && !href.startsWith("https://"))
      href = rs.urlForResourceNamed(href, framework, null, context.request());
    response._appendTagAttributeAndValue("source", href, false);
    super.appendAttributesToResponse(response, context);
  }
View Full Code Here

    return super.createReplacedElement(context, box, callback, cssWidth, cssHeight);
  }

  private NSData cachedDataForKey(String key) {
    WOResourceManager resourceManager =  WOApplication.application().resourceManager();
    WOURLValuedElementData elementData = resourceManager._cachedDataForKey(key);
    if (elementData.isTemporary()) {
      resourceManager.removeDataForKey(key, null);
    }
    return elementData.data();
  }
View Full Code Here

     */
    public static URL pathURLForResourceNamed(String fileName, String frameworkName, NSArray<String> languages) {
      URL url = null;
      WOApplication application = WOApplication.application();
      if (application != null) {
        WOResourceManager resourceManager = application.resourceManager();
        if (resourceManager != null) {
          url = resourceManager.pathURLForResourceNamed(fileName, frameworkName, languages);
        }
      }
        return url;
    }
View Full Code Here

      {
        url = fileName;
      }
      else
      {
        WOResourceManager rm = WOApplication.application().resourceManager();
        NSArray<String> languages = null;
        if (context.hasSession())
        {
          languages = context.session().languages();
        }
        url = rm.urlForResourceNamed(fileName, framework, languages, context.request());
      }
      response.appendContentString(url);
      response.appendContentString("\"></script>");

      resourceAddedInThread(framework, fileName);
View Full Code Here

        // String methodName = (String)request.stringFormValueForKey("methodName");
        line = request.numericFormValueForKey("line",new NSNumberFormatter("#0"));
        filename = request.stringFormValueForKey("filename");
        errorMessage = request.stringFormValueForKey("errorMessage");
        fullClassName = request.stringFormValueForKey("fullClassName");
        WOResourceManager resources = WOApplication.application().resourceManager();

        // pay no attention to this use of protected API
        WODeployedBundle appBundle = resources._appProjectBundle();
        if (appBundle instanceof WOProjectBundle) {
            WOProjectBundle project = (WOProjectBundle) appBundle;
            _WOProject woproject = project._woProject();
            String filePath = woproject._pathToSourceFileForClass(fullClassName, filename);
            if (filePath == null) {
View Full Code Here

TOP

Related Classes of com.webobjects.appserver.WOResourceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.