Author: echatellier Date: 2013-06-23 18:46:32 +0200 (Sun, 23 Jun 2013) New Revision: 104 Url: http://nuiton.org/projects/nuiton-js/repository/revisions/104 Log: Update upstream code Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsXmlModelFactory.java trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ProtectedXmlModelFactory.java Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java =================================================================== --- trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java 2013-06-23 16:46:18 UTC (rev 103) +++ trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java 2013-06-23 16:46:32 UTC (rev 104) @@ -187,8 +187,6 @@ // le path du pattern (c-a-d: a/b/c/) String classPath = FilenameUtils.getPath(pattern); - String toto = url.getFile(); - // recuperation du path du jar sans la partie query String jarPath = StringUtils.substringBefore(url.getPath(), "!"); jarPath = StringUtils.substringAfter(jarPath, "file:"); @@ -208,20 +206,27 @@ String prefix = "jar:" + StringUtils.substringBefore(url.getPath(), "!") + "!/"; - JarFile file = new JarFile(jarPath); - - List<JarEntry> jarEntryList = Collections.list(file.entries()); - for (final JarEntry entry : jarEntryList) { - final String entryName = entry.getName(); - //ignore the parent folder itself and accept only child resources - final boolean isSupportedEntry = entryName.startsWith(classPath) - && !entryName.equals(classPath) - && FilenameUtils.wildcardMatch(entryName, pattern); - if (isSupportedEntry) { - String u = prefix + entryName; - allFiles.add(u); - LOG.debug("\tfound jar entry: {}", entryName); + JarFile file = null; + try { + file = new JarFile(jarPath); + + List<JarEntry> jarEntryList = Collections.list(file.entries()); + for (final JarEntry entry : jarEntryList) { + final String entryName = entry.getName(); + //ignore the parent folder itself and accept only child resources + final boolean isSupportedEntry = entryName.startsWith(classPath) + && !entryName.equals(classPath) + && FilenameUtils.wildcardMatch(entryName, pattern); + if (isSupportedEntry) { + String u = prefix + entryName; + allFiles.add(u); + LOG.debug("\tfound jar entry: {}", entryName); + } } + } finally { + if (file != null) { + file.close(); + } } } else { LOG.warn("Not supported import type {}", jarPath); Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsXmlModelFactory.java =================================================================== --- trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsXmlModelFactory.java 2013-06-23 16:46:18 UTC (rev 103) +++ trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsXmlModelFactory.java 2013-06-23 16:46:32 UTC (rev 104) @@ -32,6 +32,7 @@ import ro.isdc.wro.WroRuntimeException; import ro.isdc.wro.model.WroModel; import ro.isdc.wro.model.WroModelInspector; +import ro.isdc.wro.model.group.Group; /** * On etend la classe pour forcer le chargement de toutes les librairies de @@ -107,10 +108,10 @@ for (final String groupName : new WroModelInspector(importedModel).getGroupNames()) { if (!new WroModelInspector(master).getGroupNames().contains(groupName)) { // si les deux modeles contiennent le meme groupe, on garde celui du master - master.addGroup(importedModel.getGroupByName(groupName)); + final Group importedGroup = new WroModelInspector(importedModel).getGroupByName(groupName); + master.addGroup(importedGroup); } } } - } Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ProtectedXmlModelFactory.java =================================================================== --- trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ProtectedXmlModelFactory.java 2013-06-23 16:46:18 UTC (rev 103) +++ trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ProtectedXmlModelFactory.java 2013-06-23 16:46:32 UTC (rev 104) @@ -1,39 +1,12 @@ -/* +/* %%Ignore-License * Copie exact du fichier, seul les privates sont passé en protected pour pouvoir * surcharger les methodes * */ - -package org.nuiton.js.wro; - /* - * #%L - * Nuiton JS :: WRO - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - - -/* * Copyright (c) 2008. All rights reserved. */ +package org.nuiton.js.wro; import java.io.IOException; import java.io.InputStream; @@ -91,9 +64,12 @@ /** * Logger for this class. */ - private static final Logger LOG = LoggerFactory.getLogger(ro.isdc.wro.model.factory.XmlModelFactory.class); - + private static final Logger LOG = LoggerFactory.getLogger(ProtectedXmlModelFactory.class); /** + * The alias for this model factory used by spi provider. + */ + public static final String ALIAS = "xml"; + /** * Default xml filename. */ private static final String DEFAULT_FILE_NAME = "wro.xml"; @@ -131,7 +107,8 @@ */ private static final String ATTR_GROUP_NAME = "name"; /** - * Group abstract attribute used to distinguish an abstract group when its value is true. By default the value is false. + * Group abstract attribute used to distinguish an abstract group when its value is true. By default the value is + * false. */ private static final String ATTR_GROUP_ABSTRACT = "abstract"; /** @@ -139,7 +116,6 @@ * pre processing. */ private static final String ATTR_MINIMIZE = "minimize"; - /** * Map between the group name and corresponding element. Hold the map<GroupName, Element> of all group nodes to access * any element. @@ -230,7 +206,7 @@ } return document; } catch (final Exception e) { - throw new WroRuntimeException("Cannot build model from XML", e); + throw new WroRuntimeException("Cannot build model from XML: " + e.getMessage(), e); } } @@ -284,7 +260,8 @@ } /** - * @param modelLocation the path where the model is located. + * @param modelLocation + * the path where the model is located. * @return the {@link WroModel} created from provided modelLocation. */ protected WroModel createImportedModel(final String modelLocation) { @@ -296,9 +273,14 @@ return new AutoCloseInputStream(locatorFactory.locate(modelLocation)); }; }; - //inject manually created modelFactory + // inject manually created modelFactory injector.inject(importedModelFactory); - return importedModelFactory.create(); + try { + return importedModelFactory.create(); + } catch (final WroRuntimeException e) { + LOG.error("Detected invalid model import from location {}", modelLocation); + throw e; + } } /** @@ -308,7 +290,7 @@ * to parse. */ protected void parseGroups() { - //use groups created by imports (if any) + // use groups created by imports (if any) for (final Element element : allGroupElements.values()) { parseGroup(element); } @@ -327,7 +309,7 @@ private Collection<Resource> parseGroup(final Element element) { final String name = element.getAttribute(ATTR_GROUP_NAME); final String isAbstractAsString = element.getAttribute(ATTR_GROUP_ABSTRACT); - boolean isAbstractGroup = StringUtils.isNotEmpty(isAbstractAsString) && Boolean.valueOf(isAbstractAsString); + final boolean isAbstractGroup = StringUtils.isNotEmpty(isAbstractAsString) && Boolean.valueOf(isAbstractAsString); if (groupsInProcess.contains(name)) { throw new RecursiveGroupDefinitionException("Infinite Recursion detected for the group: " + name + ". Recursion path: " + groupsInProcess); @@ -356,7 +338,7 @@ // this group is parsed, remove from unparsed collection groupsInProcess.remove(name); if (!isAbstractGroup) { - //add only non abstract groups + // add only non abstract groups model.addGroup(group); } return resources;
participants (1)
-
echatellier@users.nuiton.org