Examples of ThemeParser


Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

  }

  private void locateResourcesFromClasspath(ResourceManagerImpl resources)
      throws ServletException {

    ThemeParser parser = new ThemeParser();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
      }
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      List<URL> urls = new ArrayList<URL>();
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));

      for (URL themeUrl : urls) {
        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
          for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
            if (theme.isVersioned()) {
              String themeUrlStr = themeUrl.toString();
              int index = themeUrlStr.indexOf(META_INF_TOBAGO_CONFIG_XML);
              String metaInf = themeUrlStr.substring(0, index) + "META-INF/MANIFEST.MF";
              Properties properties = new Properties();
              final URL url = new URL(metaInf);
              InputStream inputStream = null;
              String version = null;
              try {
                inputStream = url.openStream();
                properties.load(inputStream);
                version = properties.getProperty("Implementation-Version");
              } catch (FileNotFoundException e) {
                // may happen (e. g. in tests)
                LOG.error("No Manifest-File found.");
              } finally {
                IOUtils.closeQuietly(inputStream);
              }
              if (version != null) {
                theme.setVersion(version);
              } else {
                theme.setVersioned(false);
                LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
                    + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
              }
            }
            addThemeResources(resources, themeUrl, theme);
          }
        } else {
          // the old way
          addThemeResources(resources, themeUrl, parser.parse(themeUrl));
        }
      }
    } catch (IOException e) {
      String msg = "while loading ";
      LOG.error(msg, e);
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

    TobagoConfigImpl config = new TobagoConfigImpl();
    ThemeBuilder themeBuilder = new ThemeBuilder(config);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    ThemeParser parser = new ThemeParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      ThemeResources resources = theme.getResources();
      ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(2, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/tobago-logging.js", resources.getScriptList().get(1).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertNull(theme3.getResources());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertNull(theme4.getResources());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

  }

  private void locateResourcesFromClasspath(ResourceManagerImpl resources)
      throws ServletException {

    ThemeParser parser = new ThemeParser();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
      }
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      List<URL> urls = new ArrayList<URL>();
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));

      for (URL themeUrl : urls) {
        ThemeImpl theme;
        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
          theme = (ThemeImpl) tobagoConfig.getThemeDefinitions().get(0);
        } else {
          // the old way
          theme = parser.parse(themeUrl);
        }
        themeBuilder.addTheme(theme);
        String prefix = ensureSlash(theme.getResourcePath());

        String protocol = themeUrl.getProtocol();
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

  }

  private void locateResourcesFromClasspath(ResourceManagerImpl resources)
      throws ServletException {

    ThemeParser parser = new ThemeParser();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
      }
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      List<URL> urls = new ArrayList<URL>();
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));

      for (URL themeUrl : urls) {
        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
          for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
            if (theme.isVersioned()) {
              String themeUrlStr = themeUrl.toString();
              int index = themeUrlStr.indexOf(META_INF_TOBAGO_CONFIG_XML);
              String metaInf = themeUrlStr.substring(0, index) + "META-INF/MANIFEST.MF";
              Properties properties = new Properties();
              InputStream inputStream = new URL(metaInf).openStream();
              try {
                properties.load(inputStream);
                String version = properties.getProperty("Implementation-Version");
                if (version != null) {
                  theme.setVersion(version);
                } else {
                  theme.setVersioned(false);
                  LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
                      + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
                }

              } finally {
                IOUtils.closeQuietly(inputStream);
              }
            }
            addThemeResources(resources, themeUrl, theme);
          }
        } else {
          // the old way
          addThemeResources(resources, themeUrl, parser.parse(themeUrl));
        }
      }
    } catch (IOException e) {
      String msg = "while loading ";
      LOG.error(msg, e);
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

  }

  private void locateResourcesFromClasspath(ResourceManagerImpl resources)
      throws ServletException {

    ThemeParser parser = new ThemeParser();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
      }
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      List<URL> urls = new ArrayList<URL>();
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));

      for (URL themeUrl : urls) {
        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
          for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
            addThemeResources(resources, themeUrl, theme);
          }
        } else {
          // the old way
          addThemeResources(resources, themeUrl, parser.parse(themeUrl));
        }
      }
    } catch (IOException e) {
      String msg = "while loading ";
      LOG.error(msg, e);
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

  }

  private void locateResourcesFromClasspath(ResourceManagerImpl resources)
      throws ServletException {

    ThemeParser parser = new ThemeParser();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
      }
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      List<URL> urls = new ArrayList<URL>();
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));

      for (URL themeUrl : urls) {
        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
          for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
            addThemeResources(resources, themeUrl, theme);
          }
        } else {
          // the old way
          addThemeResources(resources, themeUrl, parser.parse(themeUrl));
        }
      }
    } catch (IOException e) {
      String msg = "while loading ";
      LOG.error(msg, e);
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

    TobagoConfigImpl config = new TobagoConfigImpl();
    ThemeBuilder themeBuilder = new ThemeBuilder(config);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    ThemeParser parser = new ThemeParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      ThemeResources resources = theme.getResources();
      ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(2, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/logging.js", resources.getScriptList().get(1).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertNull(theme3.getResources());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertNull(theme4.getResources());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
View Full Code Here

Examples of org.apache.myfaces.tobago.internal.config.ThemeParser

    TobagoConfigImpl config = new TobagoConfigImpl();
    ThemeBuilder themeBuilder = new ThemeBuilder(config);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    ThemeParser parser = new ThemeParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      ThemeResources resources = theme.getResources();
      ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(2, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/logging.js", resources.getScriptList().get(1).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertNull(theme3.getResources());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertNull(theme4.getResources());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.