From: <jbo...@li...> - 2006-05-18 17:38:17
|
Author: adamw Date: 2006-05-18 13:38:01 -0400 (Thu, 18 May 2006) New Revision: 4315 Removed: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesElementValue.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java Modified: labs/shotoku/trunk/project.properties labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandlerManager.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/RemoteFeedTagHandler.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/MultiValueVariableResolver.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/Substitution.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-36 Modified: labs/shotoku/trunk/project.properties =================================================================== --- labs/shotoku/trunk/project.properties 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/project.properties 2006-05-18 17:38:01 UTC (rev 4315) @@ -5,7 +5,7 @@ shotoku.sar.dir=shotoku.sar shotoku.subprojects.cms=base,files,jcr,svn -shotoku.subprojects=${shotoku.subprojects.cms},aop,test,web,portal,admin +shotoku.subprojects=${shotoku.subprojects.cms},aop,test,web,admin,feeds,portal maven.final.name=${pom.artifactId} Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -1,60 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This 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 2.1 of - * the License, or (at your option) any later version. - * - * This software 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.shotoku.tools; - -import java.io.ByteArrayOutputStream; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Node; - -/** - * @author adamw - * @author Ryszard Kozmik - * A helper class to transform DOM nodes to their string representations - * in XML. - */ -public class DomToXmlTransformer { - /** - * Creates a string-xml representation of the given node. - * @param root Node to transform - * @return A string contating data from the given node in a XML format. - * @throws TransformerException - */ - public String transformNode(Node root) throws TransformerException { - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = tFactory.newTransformer();; - transformer.setOutputProperty(OutputKeys.INDENT,"yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - transformer.transform(new DOMSource(root), new StreamResult(bos)); - - return bos.toString(); - } -} Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesElementValue.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesElementValue.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesElementValue.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -1,133 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This 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 2.1 of - * the License, or (at your option) any later version. - * - * This software 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.shotoku.tools; - -import java.util.List; -import java.util.ArrayList; - -/** - * A class for holding single or multiple values. - * - * @author adamw - */ -public class PropertiesElementValue { - private String single; - private List<String> multi; - - /** - * Creates a new instance with no values. - */ - public PropertiesElementValue() { - single = null; - multi = null; - } - - /** - * Crates a new instance with an initial single value. - * - * @param initialValue - * Initial value to hold. - */ - public PropertiesElementValue(String initialValue) { - this(); - add(initialValue); - } - - /** - * Crates a new instance with values copied from the given - * element values. - * - * @param initialValues - * Initial values to add. - */ - public PropertiesElementValue(PropertiesElementValue initialValues) { - this(); - add(initialValues); - } - - private void singleToMulti() { - multi = new ArrayList<String>(); - - if (single != null) { - multi.add(single); - single = null; - } - } - - /** - * Adds all values from the given element values. - * - * @param ev - * Values to add. - */ - public void add(PropertiesElementValue ev) { - // Converting our values to a list of values. - singleToMulti(); - multi.addAll(ev.getAllValues()); - } - - /** - * Adds a value. - * - * @param value - * Value to add. - */ - public void add(String value) { - if ((single == null) && (multi == null)) - single = value; - else if (multi != null) - multi.add(value); - else { - singleToMulti(); - multi.add(value); - } - } - - /** - * Gets the first held value. - * - * @return First held value or null, if no value is held. - */ - public String getFirstValue() { - if (single == null) { - if (multi == null) - return null; - - return multi.get(0); - } - - return single; - } - - /** - * Gets all held values. - * - * @return A list of held values or null, if no values are held. - */ - public List<String> getAllValues() { - if (single != null) { - singleToMulti(); - } - - return multi; - } -} Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -1,136 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This 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 2.1 of - * the License, or (at your option) any later version. - * - * This software 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.shotoku.tools; - -import java.util.Map; -import java.util.HashMap; -import java.util.Set; - -/** - * A class describing properties with multiple or single values. - * - * @author adamw - */ -public class PropertiesMap { - private Map<String, PropertiesElementValue> properties; - - /** - * Creates an empty properties map, with no bindings. - */ - public PropertiesMap() { - properties = new HashMap<String, PropertiesElementValue>(); - } - - /** - * Binds with the given key, the given value. - * - * @param key - * Key which to bind. - * @param value - * Value which should be added to the currently held values under - * the given key. - */ - public void add(String key, String value) { - PropertiesElementValue ev = properties.get(key); - if (ev == null) - properties.put(key, new PropertiesElementValue(value)); - else - ev.add(value); - } - - /** - * Binds with the given key the given values. - * - * @param key - * Key of the values. - * @param ev - * Value representation. - */ - public void put(String key, PropertiesElementValue ev) { - properties.put(key, ev); - } - - /** - * Gets the values that are bound to the given key. If no values are bound, - * a single-value "null" is returned. - * - * @param key - * Key to look for. - * @return Values corresponding to this key or a value "" if no values - * are bound. - */ - public PropertiesElementValue get(String key) { - PropertiesElementValue ev = properties.get(key); - if (ev == null) - return new PropertiesElementValue(""); - - return ev; - } - - /** - * Checks if there are any value bound to the given key. - * @param key Key to check. - * @return True iff any values are bound with the given key. - */ - public boolean hasValues(String key) { - return properties.containsKey(key); - } - - /** - * Binds with the given key, the given element values. - * - * @param key - * Key which to bind. - * @param value - * Values which should be added to the currently held values under - * the given key. - */ - public void add(String key, PropertiesElementValue value) { - PropertiesElementValue ev = properties.get(key); - if (ev == null) - properties.put(key, new PropertiesElementValue(value)); - else - ev.add(value); - } - - /** - * Adds all properties from the given properties map to this properties - * map. - * @param pm A properties map from which to add all the properties. - */ - public void add(PropertiesMap pm, boolean overwrite) { - for (String key : pm.properties.keySet()) { - if (overwrite) - properties.remove(key); - - add(key, pm.properties.get(key)); - } - } - - /** - * Gets a set of all keys held in this map. - * @return A set of all keys in this map. - */ - public Set<String> getKeySet() { - return properties.keySet(); - } -} Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -26,15 +26,18 @@ import java.nio.charset.Charset; import java.nio.channels.FileChannel; import java.util.Random; +import java.util.Map; +import java.util.HashMap; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.service.ShotokuService; import org.jboss.shotoku.service.ShotokuServiceImpl; -import org.jboss.shotoku.service.AdministratedService; import org.jboss.shotoku.exceptions.RepositoryException; import org.jboss.shotoku.exceptions.NameFormatException; import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; +import org.w3c.dom.Node; +import org.w3c.dom.NamedNodeMap; import javax.activation.MimetypesFileTypeMap; @@ -115,7 +118,30 @@ return unmarshallText(n); } + /** + * Reads all attributes of the given node and returns them as a map. Only + * signle-value attributes are supported. + * @param root Node from which to read the attributes. + * @return A map holding all attributes of the given node. + */ + public static Map<String, String> getMapFromNodeAttributes(Node root) { + Map<String, String> properties = new HashMap<String, String>(); + NamedNodeMap nnm = root.getAttributes(); + if (nnm != null) { + Node n; + + for (int i=0; i<nnm.getLength(); i++) { + n = nnm.item(i); + if (n.getNodeType() == Node.ATTRIBUTE_NODE) { + properties.put(n.getNodeName(), Tools.unmarshallText(n)); + } + } + } + + return properties; + } + /** * From the given string, removes unnecessary / in the middle and * ending. If startingSlash = true, ensures that the returned string Deleted: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -1,266 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This 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 2.1 of - * the License, or (at your option) any later version. - * - * This software 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.shotoku.tools; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.transform.TransformerException; - -import org.jboss.shotoku.tools.DomToXmlTransformer; -import org.jboss.shotoku.tools.PropertiesMap; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Common helper xml parsing functions. - * - * @author adamw - * @author Pawel Wrzeszcz - */ -public class XmlTools { - /** - * This class cannot be instatiated. - */ - private XmlTools() { - - } - - /** - * Reads all attributes of the given node and returns them as a properties map. - * @param root Node from which to read the attributes. - * @return A properties map holding all attributes of the given node. - */ - public static PropertiesMap getPropertiesFromNodeAttributes(Node root) { - PropertiesMap properties = new PropertiesMap(); - NamedNodeMap nnm = root.getAttributes(); - - if (nnm != null) { - Node n; - - for (int i=0; i<nnm.getLength(); i++) { - n = nnm.item(i); - if (n.getNodeType() == Node.ATTRIBUTE_NODE) { - properties.add(n.getNodeName(), XmlTools.unmarshallText(n)); - } - } - } - - return properties; - } - - /** - * Reads all attributes of the given node and returns them as a map. Only - * signle-value attributes are supported. - * @param root Node from which to read the attributes. - * @return A map holding all attributes of the given node. - */ - public static Map<String, String> getMapFromNodeAttributes(Node root) { - Map<String, String> properties = new HashMap<String, String>(); - NamedNodeMap nnm = root.getAttributes(); - - if (nnm != null) { - Node n; - - for (int i=0; i<nnm.getLength(); i++) { - n = nnm.item(i); - if (n.getNodeType() == Node.ATTRIBUTE_NODE) { - properties.put(n.getNodeName(), XmlTools.unmarshallText(n)); - } - } - } - - return properties; - } - - /** - * Reads all child nodes of the given node and returns them as a map. - * - * @param root Node from which to read the child nodes. - * @return A map binding child nodes names with their values. - */ - public static Map<String, String> getMapFromNodeElements(Node root) { - Map<String,String> properties = new HashMap<String,String>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE) { - properties.put(n.getNodeName(), XmlTools.unmarshallText(n)); - } - } - - return properties; - } - - /** - * Reads all child nodes of the given node and returns them as a map. - * - * @param root Node from which to read the child nodes. - * @return A map binding child nodes names with appropriate nodes. - */ - public static Map<String, Node> getNodeMapFromNodeElements(Node root) { - Map<String, Node> properties = new HashMap<String, Node>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE) { - properties.put(n.getNodeName(), n); - } - } - - return properties; - } - - /** - * From the given node, gets the value of the specified attribute. - * @param root Node to read the attribute from. - * @param attrName Name of the attribute to read. - * @return Value of the given attribute or null, if no such attribute - * is present. - */ - public static String getAttributeValue(Node root, String attrName) { - NamedNodeMap attrMap = root.getAttributes(); - if (attrMap == null) return null; - - Node n = attrMap.getNamedItem(attrName); - if (n == null) return null; - - return unmarshallText(n); - } - - /** - * Reads and returns a HTML block contained in the children of the specified - * node. - * @param root Node from which's children to get the HTML block. - * @param xht An instance of a dom to xml transformer. - * @return A string representation of the html contained in the given - * node. - */ - public static String unmarshallHtml(Node root, DomToXmlTransformer xht) { - StringBuffer buf = new StringBuffer(); - - Node n; - NodeList nodes = root.getChildNodes(); - - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - - try { - buf.append(xht.transformNode(n)); - } catch (TransformerException e) { - return "Transformation error"; - } - } - - return buf.toString(); - } - - /** - * Reads and returns a HTML block contained in the children of the specified - * node with a default xml -> html transformer. - * @param root Node from which's children to get the HTML block. - * @return A string representation of the html contained in the given - * node. - */ - public static String unmarshallHtml(Node root) { - return unmarshallHtml(root, new DomToXmlTransformer()); - } - - /** - * Reads and returns a xml block contained in the entire specified - * node. - * @param root Node from which's to get the xml block. - * @return A string representation of the xml contained in the given - * node, including this node's representation. - */ - public static String unmarshallXml(Node root) { - try { - return new DomToXmlTransformer().transformNode(root); - } catch (TransformerException e) { - return ""; - } - } - - /** - * Gets a node that is a child node of the given one and has the given - * name. - * @param root Node which children are to be searched. - * @param name Name of the searched node. - * @return A child node with the given name or null, if no such node - * exists. - */ - public static Node getFirstNodeWithName(Node root, String name) { - NodeList children = root.getChildNodes(); - - for (int i = 0; i < children.getLength(); i++) { - Node n = children.item(i); - if (name.equalsIgnoreCase(n.getNodeName())) - return n; - } - - return null; - } - - /** - * Gets value of a node that is a child node of the given one and has the - * given name - * - * @param root Node which children are to be searched. - * @param childNodeName Name of the searched node. - * @return A value of child node with the given ame or null, if no such - * node exists. - */ - public static String getChildNodeValue(Node root, String childNodeName) { - Node node = getFirstNodeWithName(root, childNodeName); - - if (node != null) { - return unmarshallText(node); - } - - return null; - } - - /** - * Reads text contained in a tag of the form <tag>text</tag>. - * @param textNode Node to read text from. - * @return Text contained in the given node. - */ - public static String unmarshallText(Node textNode) { - StringBuffer buf = new StringBuffer(); - - Node n; - NodeList nodes = textNode.getChildNodes(); - - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - - if (n.getNodeType() == Node.TEXT_NODE) { - buf.append(n.getNodeValue()); - } - } - - return buf.toString(); - } -} Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandlerManager.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandlerManager.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandlerManager.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -67,7 +67,7 @@ Matcher m = variablesPattern.matcher(text); while (m.find()) { - toFill.add(text.substring(m.start(), m.end()+1)); + toFill.add(text.substring(m.start(), m.end())); } } } @@ -86,7 +86,6 @@ // Getting an appropriate construtor to the given feed tag type. Constructor handlerConstr = handlers.get(definition.getNodeName()); if (handlerConstr == null) { - log.error("Unknown feed tag: " + definition.getNodeName() + "."); return; } @@ -112,6 +111,7 @@ // For each substitution, adding a tag handler to FeedsDescriptor. for (Substitution s : substitutions) { String feedName = s.make(feedNameAttr); + try { fd.addFeedTagHandler(feedName, s.getSubstitutionFor(Constants.TYPE_VARIABLE), (FeedTagHandler) handlerConstr.newInstance(feedName, group, definition, s)); Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/RemoteFeedTagHandler.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/RemoteFeedTagHandler.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/RemoteFeedTagHandler.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -35,7 +35,7 @@ feed.generate(new URL(address)); fd.addFeed(feedName, feedType, feed); } catch (Exception e) { - log.debug("Can't add feed " + address + " : " + feedType + ".", e); + log.error("Can't add feed " + address + " : " + feedType + ".", e); return false; } Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -57,16 +57,17 @@ addParamSimple("and", AndNodeFilter.class); addParamSimple("or", OrNodeFilter.class); - addParamSimple("property-value", PropertyValueParameter.class); addParamSimple("search", Search.class); addParamSimple("shotoku-feed", Search.class); + addParamSimple("date-sort", DateSortParameter.class); + + addParamParametrized("property-value", PropertyValueParameter.class); addParamParametrized("directory", DirectoryIncludeParameter.class); addParamParametrized("history", HistoryIncludeParameter.class); addParamParametrized("limit", LimitParameter.class); addParamParametrized("property-sort", PropertySortParameter.class); - addParamParametrized("date-sort", DateSortParameter.class); } /** @@ -156,6 +157,8 @@ } vc.put(searchNameAttr, list); + + break; } catch (Exception e) { log.error("Error generating shotoku feed " + getFeedName() + ".", e); Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/MultiValueVariableResolver.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/MultiValueVariableResolver.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/MultiValueVariableResolver.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -1,5 +1,7 @@ package org.jboss.shotoku.feeds.variables; +import org.jboss.shotoku.feeds.Constants; + import java.util.Set; import java.util.HashSet; Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/Substitution.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/Substitution.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/Substitution.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -66,6 +66,7 @@ ret = (Substitution) super.clone(); ret.substitutions = new HashMap<Pattern, String>(substitutions); + ret.substitutionsSource = new HashMap<String, String>(substitutionsSource); return ret; } catch (CloneNotSupportedException e) { Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -42,7 +42,7 @@ try { varResolversEmptyConstructor.put(variable, varResolverClass.getConstructor()); } catch (NoSuchMethodException e1) { - log.error("No (org.w3c.dom.Node) or () constructor foound for variable " + + log.error("No (org.w3c.dom.Node) or () constructor found for variable " + props.getProperty(id + Constants.ONE_VAR + variable) + " resolver " + varResolverClass.getName() + ".", e); } Modified: labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java =================================================================== --- labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java 2006-05-18 14:57:13 UTC (rev 4314) +++ labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java 2006-05-18 17:38:01 UTC (rev 4315) @@ -2,6 +2,8 @@ import java.util.Set; import java.util.HashSet; +import java.util.regex.Pattern; +import java.util.regex.Matcher; /** * @author Adam Warski (ad...@as...) @@ -20,10 +22,26 @@ a[2] = 10; } + /** + * A pattern which matcher variables of the form "${text with numbers}". + */ + private final static Pattern variablesPattern = Pattern.compile( + Pattern.quote("${") + "[a-zA-Z0-9]*" + Pattern.quote("}")); + + private static void addVariablesFromNode(String text) { + Matcher m = variablesPattern.matcher(text); + + while (m.find()) { + System.out.println(text.substring(m.start(), m.end())); + } + } + public static void main(String[] args) { - int[] t = {1, 2, 3}; + /*int[] t = {1, 2, 3}; System.out.println(t[2]); x(t); - System.out.println(t[2]); + System.out.println(t[2]);*/ + + addVariablesFromNode("templates/${type}-normal.vm"); } } |