From: <jbo...@li...> - 2006-05-17 22:13:11
|
Author: adamw Date: 2006-05-17 18:12:56 -0400 (Wed, 17 May 2006) New Revision: 4292 Removed: labs/shotoku/trunk/shotoku-feeds/src/web/WEB-INF/tld/forge.tld Modified: labs/shotoku/trunk/shotoku-feeds/project.properties labs/shotoku/trunk/shotoku-feeds/project.xml labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsServlet.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/Feed.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/FileBasedFeed.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/AggregatedFeedTagHandler.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandler.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/Substitution.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java labs/shotoku/trunk/shotoku-feeds/src/web/WEB-INF/web.xml Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-36 Modified: labs/shotoku/trunk/shotoku-feeds/project.properties =================================================================== --- labs/shotoku/trunk/shotoku-feeds/project.properties 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/project.properties 2006-05-17 22:12:56 UTC (rev 4292) @@ -1,7 +1,9 @@ -maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ +maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven maven.junit.fork=yes maven.war.src=${basedir}/src/web +maven.final.name=${pom.artifactId} + maven.jar.override=on maven.jar.informa=${shotoku.root.dir}/shotoku-feeds/lib/informa.jar Modified: labs/shotoku/trunk/shotoku-feeds/project.xml =================================================================== --- labs/shotoku/trunk/shotoku-feeds/project.xml 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/project.xml 2006-05-17 22:12:56 UTC (rev 4292) @@ -7,7 +7,7 @@ <project> <pomVersion>3</pomVersion> <extend>../project.xml</extend> - <id>feeds</id> + <id>shotoku-feeds</id> <name>Shotoku Feeds</name> <currentVersion>1.0</currentVersion> <organization> @@ -24,6 +24,12 @@ </dependency> <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-aop</artifactId> + <jar>shotoku-aop.jar</jar> + </dependency> + + <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet</artifactId> <jar>javax.servlet.jar</jar> @@ -78,7 +84,7 @@ <dependency> <groupId>xerces</groupId> <artifactId>xmlParserAPIs</artifactId> - <version>2.8.0</version> + <version>2.6.2</version> <properties> <war.bundle>true</war.bundle> </properties> @@ -92,6 +98,12 @@ <war.bundle>true</war.bundle> </properties> </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + </dependency> </dependencies> <build> Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -22,50 +22,26 @@ package org.jboss.shotoku.feeds; import java.io.IOException; -import java.io.Writer; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Constructor; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import org.apache.velocity.VelocityContext; import org.apache.xerces.parsers.DOMParser; -import org.jboss.shotoku.tools.XmlTools; -import org.jboss.logging.Logger; +import org.apache.log4j.Logger; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.feeds.data.Feed; -import org.jboss.shotoku.feeds.tools.RdfDateFormat; -import org.jboss.shotoku.feeds.tools.TextEscaping; -import org.jboss.shotoku.feeds.variables.VariableResolver; -import org.jboss.shotoku.feeds.variables.NullVariableResolver; -import org.jboss.shotoku.feeds.variables.Substitution; import org.jboss.shotoku.feeds.variables.VariableResolverManager; -import org.jboss.shotoku.feeds.tag.FeedDefinition; import org.jboss.shotoku.feeds.tag.FeedTagHandler; import org.jboss.shotoku.feeds.tag.FeedTagHandlerManager; import org.jboss.shotoku.tools.Pair; import org.jboss.shotoku.tools.Tools; import org.jboss.shotoku.aop.CacheItem; -import org.jboss.shotoku.search.Search; -import org.jboss.shotoku.search.SearchParameter; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -77,28 +53,8 @@ * @author da...@si... */ public class FeedsDescriptor { -/* -# Shotoku feeds properites - search parameters classes -search.shotoku-feed = org.jboss.shotoku.search.Search - -search.and = org.jboss.shotoku.search.AndNodeFilter -search.or = org.jboss.shotoku.search.OrNodeFilter -search.property-value = org.jboss.shotoku.search.PropertyValueParameter - -search.directory = org.jboss.shotoku.search.DirectoryIncludeParameter -search.history = org.jboss.shotoku.search.HistoryIncludeParameter -search.limit = org.jboss.shotoku.search.LimitParameter -search.property-sort = org.jboss.shotoku.search.PropertySortParameter -search.date-sort = org.jboss.shotoku.search.DateSortParameter - -search.search = org.jboss.shotoku.search.Search - -search.parametrized = directory,history,limit,property-sort,property-value -*/ - private static final Logger log = Logger.getLogger(FeedsDescriptor.class); - @CacheItem private static FeedsCache feedsCache; @@ -106,28 +62,38 @@ private static FeedsConfigurationWatcher conf; static synchronized FeedsDescriptor getInstance(String id, String baseServerAddress) { - return feedsCache.get(new Pair<String, String>(id, baseServerAddress)); - } + return feedsCache.get(new Pair<String, String>(id, baseServerAddress)); + } - /** - * Ready feeds: feed name -> (feed type -> feed). - */ - private Map<String, Map<String, Feed>> feeds; + /** + * Ready feeds: feed name -> (feed type -> feed). + */ + private Map<String, Map<String, Feed>> feeds; - /** - * Feed group display name -> set of feed - * names. - */ - private Map<String, Set<String>> feedGroups; + /** + * Feed group display name -> set of feed + * names. + */ + private Map<String, Set<String>> feedGroups; private VariableResolverManager vrm; - private Map<String, FeedTagHandler> feedTagHandlers; + /** + * Feed tag handlers (not yet generated): feed name -> (feed type -> feed + * tag handler). + */ + private Map<String, Map<String, FeedTagHandler>> feedTagHandlers; + /** + * A set of feed names that are currently generated (used to detect looping + * feed definitions). + */ + private Set<String> duringGeneration; + private String baseServerAddress; - public FeedsDescriptor(String id, String baseServerAddress) { - this.baseServerAddress = baseServerAddress; + public FeedsDescriptor(String id, String baseServerAddress) { + this.baseServerAddress = baseServerAddress; // From the global Shotoku configuration, reading the config file // location in Shotoku repositories. @@ -144,93 +110,112 @@ ); vrm = new VariableResolverManager(id, props); - feedTagHandlers = new HashMap<String, FeedTagHandler>(); + feedTagHandlers = new HashMap<String, Map<String, FeedTagHandler>>(); // Creating the maps that will hold the feeds. - feeds = new HashMap<String, Map<String, Feed>>(); - feedGroups = new LinkedHashMap<String, Set<String>>(); + feeds = new HashMap<String, Map<String, Feed>>(); + feedGroups = new LinkedHashMap<String, Set<String>>(); - // Looking for file containing feed definitons and filling the maps. - for (org.jboss.shotoku.Node feedNode : + // Looking for file containing feed definitons and filling the maps. + for (org.jboss.shotoku.Node feedNode : cm.getRootDirectory().getNodes().toList()) { - if (feedNode.getName().endsWith(Constants.NODE_ENDING)) { - try { - addFeedDefinitions(feedNode); - } catch (Exception e) { - // We just don't add the feeds ... and log a warning. - log.warn("Can't add feed definitions from node " + + if (feedNode.getName().endsWith(Constants.NODE_ENDING)) { + try { + addFeedDefinitions(feedNode); + } catch (Exception e) { + // We just don't add the feeds ... and log a warning. + log.warn("Can't add feed definitions from node " + feedNode.getFullName() + ".", e); - } - } - } + } + } + } // Generating the feeds. + duringGeneration = new HashSet<String>(); while (feedTagHandlers.size() > 0) { // Trying to generate any feed found in the feed tag handler map. - generateFeed(feedTagHandlers.keySet().iterator().next(), - new HashSet<String>()); + generateFeed(feedTagHandlers.keySet().iterator().next()); } + + // TODO populate the groups } - private void addFeedDefinitions(org.jboss.shotoku.Node node) throws SAXException, IOException { - DOMParser parser = new DOMParser(); - // Parse the descriptor at the given Shotoku node. - parser.parse(new InputSource(node.getContentInputStream())); - // Get the XML document element of the feed descriptor file. - Node root = parser.getDocument().getDocumentElement(); + private void addFeedDefinitions(org.jboss.shotoku.Node node) throws SAXException, IOException { + DOMParser parser = new DOMParser(); + // Parse the descriptor at the given Shotoku node. + parser.parse(new InputSource(node.getContentInputStream())); + // Get the XML document element of the feed descriptor file. + Node root = parser.getDocument().getDocumentElement(); String group = Tools.getAttributeValue(root, "display-name"); Set<String> feedGroup = new LinkedHashSet<String>(); - // Each feed descriptor file has one feed group. - // Get the name of the feed group for this file. - feedGroups.put(group, feedGroup); + // Each feed descriptor file has one feed group. + // Get the name of the feed group for this file. + feedGroups.put(group, feedGroup); - NodeList nodes = root.getChildNodes(); + NodeList nodes = root.getChildNodes(); - // Iterate through the rest of the feed descriptor - // file to load all feeds for a given feed group. - for (int i = 0; i < nodes.getLength(); i++) { - Node n = nodes.item(i); - feedTagHandlers.putAll(FeedTagHandlerManager.getHandlers(group, n, vrm)); - } - } + // Iterate through the rest of the feed descriptor + // file to load all feeds for a given feed group. + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + FeedTagHandlerManager.createHandlers(group, n, vrm, this); + } + } /** - * Adds a feed of the given name and type. - * @param name - * @param type - * @param feed - */ - public void addFeed(String name, String type, Feed feed) { - Map<String, Feed> typesMap = feeds.get(name); - if (typesMap == null) { - typesMap = new HashMap<String, Feed>(); - feeds.put(name, typesMap); - } + * Adds a feed tag handler of the given name and type. + * @param name + * @param type + * @param fth + */ + public void addFeedTagHandler(String name, String type, FeedTagHandler fth) { + Map<String, FeedTagHandler> typesMap = feedTagHandlers.get(name); + if (typesMap == null) { + typesMap = new HashMap<String, FeedTagHandler>(); + feedTagHandlers.put(name, typesMap); + } - typesMap.put(type, feed); - } + typesMap.put(type, fth); + } /** + * Adds a ready feed of the given name and type. + * @param name + * @param type + * @param feed + */ + public void addFeed(String name, String type, Feed feed) { + Map<String, Feed> typesMap = feeds.get(name); + if (typesMap == null) { + typesMap = new HashMap<String, Feed>(); + feeds.put(name, typesMap); + } + + typesMap.put(type, feed); + } + + /** * Tries to generate a feed with the given name. If the feed is absent, * or is being already generated (this case indicates a loop in feed * definitions), no actions are taken. * @param name Feed to be generated. - * @param duringGeneration Set of feed names that are being generated - * at the moment (not yet added). * @return True iff generation was successfull. */ - public boolean generateFeed(String name, Set<String> duringGeneration) { + public boolean generateFeed(String name) { if (duringGeneration.contains(name)) { return false; } - FeedTagHandler fth = feedTagHandlers.get(name); - if (fth != null) { + Map<String, FeedTagHandler> typeMap = feedTagHandlers.get(name); + if (typeMap != null) { feedTagHandlers.remove(name); - + duringGeneration.add(name); - boolean ret = fth.generate(this, duringGeneration); + boolean ret = true; + for (FeedTagHandler fth : typeMap.values()) { + ret &= fth.generate(this); + } duringGeneration.remove(name); return ret; @@ -240,97 +225,35 @@ } /** - * In the given <code>map</code>, in its values, replaces each occurence of - * <code>replaceWhat</code> with <code>replaceTo</code>. - * @param map - * @param replaceWhat - * @param replaceTo - * @return <code>map</code> - */ - private Map<String, String> replaceInMapValues(Map<String, String> map, - String replaceWhat, String replaceTo) { - for (String key : map.keySet()) { - map.put(key, map.get(key).replace(replaceWhat, replaceTo)); - } + * Gets a feed of the given type and name. + * @param name Name of the feed to get. + * @param type Type of the feed to get. + * @return Feed with the given name and type. + */ + public Feed getFeed(String name, String type) { + Map<String, Feed> feedTypes = feeds.get(name); + if (feedTypes == null) + return null; - return map; - } + return feedTypes.get(type); + } - /** - * Generates a link to a specified feed. If the link is to be full, an - * absolute address is returned. Otherwise, a relative one. - * @param full - * @param feedName - * @param feedType - * @return - */ - private String generateFeedLink(boolean full, String feedName, - String feedType) { - return (full ? baseServerAddress : "") + "/feeds/" + feedName + "/" - + feedType; - } + public String getBaseServerAddress() { + return baseServerAddress; + } - /** - * Gets a feed of the given type and name. - * @param name Name of the feed to get. - * @param type Type of the feed to get. - * @return Feed with the given name and type. - */ - public Feed getFeed(String name, String type) { - Map<String, Feed> feedTypes = feeds.get(name); - if (feedTypes == null) - return null; + public VariableResolverManager getVariableResolverManager() { + return vrm; + } - return feedTypes.get(type); - } - /** * Releases all feeds - deletes temporary files which contain them. */ public void release() { - + for (Map<String, Feed> feedTypes : feeds.values()) { + for (Feed feed : feedTypes.values()) { + feed.release(); + } + } } - - /** - * Fills the <code>context</code> variable with feed information that is - * to be shown in the portlet. - */ - private void fillContext() { - String[] allFeedTypes = FeedFactory.getAllFeedTypes(); - - context = new DelegateContext(); - for (String feedGroup : feedGroups.keySet()) { - Set<String> feedsInGroup = feedGroups.get(feedGroup); - - if (feedsInGroup.size() > 0) { - DelegateContext groupContext = context.next("groups"); - groupContext.put("name", feedGroup); - - for (String feedName : feedsInGroup) { - Map<String, Feed> feedTypes = feeds.get(feedName); - - if (feedTypes != null) { - DelegateContext feedContext = groupContext - .next("feeds"); - feedContext.put("name", - feedDisplayNames.get(feedName)); - - Set availableTypes = feedTypes.keySet(); - for (String feedType : allFeedTypes) { - DelegateContext typeContext = feedContext - .next("types"); - - if (availableTypes.contains(feedType)) { - typeContext.next("feed"); - typeContext.put("name", feedType); - typeContext.put("link", generateFeedLink(false, - feedName, feedType)); - } - } - } - } - } - } - } - } Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsServlet.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsServlet.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsServlet.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -24,11 +24,11 @@ import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.ServletRequest; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jboss.forge.common.ForgeHelper; import org.jboss.shotoku.feeds.data.Feed; public class FeedsServlet extends HttpServlet { @@ -37,6 +37,15 @@ response.getWriter().println("The feed you requested is not available."); } + private static String makeAddress(String scheme, String server, int port) { + return scheme + "://" + server + ":" + port; + } + + public static String getBaseServerAddress(ServletRequest request) { + return makeAddress(request.getScheme(), request.getServerName(), + request.getServerPort()); + } + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -60,8 +69,8 @@ String type = requestURI.substring(lastSlash+1); String name = requestURI.substring(0, lastSlash); - Feed feed = FeedsDescriptor.getInstance(ForgeHelper.LABS_PORTAL, - ForgeHelper.getBaseServerAddress(request)).getFeed(name, type); + Feed feed = FeedsDescriptor.getInstance("default", + getBaseServerAddress(request)).getFeed(name, type); if (feed == null) { invalidRequest(response); Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/Feed.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/Feed.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/Feed.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -91,4 +91,9 @@ * @return Type of this feed. */ public String getType(); + /** + * Called when this feed is no longer needed, so that any resources can + * be released (like temporary files). + */ + public void release(); } Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/FileBasedFeed.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/FileBasedFeed.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/FileBasedFeed.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -131,4 +131,8 @@ public String getType() { return type; } + + public void release() { + file.delete(); + } } Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/AggregatedFeedTagHandler.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/AggregatedFeedTagHandler.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/AggregatedFeedTagHandler.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -4,120 +4,91 @@ import org.w3c.dom.NodeList; import org.jboss.shotoku.feeds.data.Feed; import org.jboss.shotoku.feeds.FeedFactory; +import org.jboss.shotoku.feeds.FeedsDescriptor; +import org.jboss.shotoku.feeds.Constants; +import org.jboss.shotoku.feeds.variables.Substitution; +import org.jboss.shotoku.tools.Tools; +import org.apache.log4j.Logger; import java.util.*; +import java.io.IOException; /** * @author Adam Warski (ad...@as...) */ public class AggregatedFeedTagHandler extends FeedTagHandler { - public AggregatedFeedTagHandler(String group, Node definition) { - super(group, definition); + private static final Logger log = Logger.getLogger(FeedsDescriptor.class); + + public AggregatedFeedTagHandler(String feedName, String group, Node definition, Substitution s) { + super(feedName, group, definition, s); } - private void generateAggregatedFeeds(Map<String, Node> feedDefs) { - // First building requirements of each feed - that is, whit which - // feeds each aggregated feed is built. - Map<String, Set<String>> requirements = - new HashMap<String, Set<String>>(); - Map<String, String[]> parameters = new HashMap<String, String[]>(); + public boolean generate(FeedsDescriptor fd) { + String feedName = getFeedName(); + String feedType = getFeedType(); + Node definition = getDefinition(); - // Gathering information about defined feeds, their requirements - // (that is, from which other feeds they are composed) and their - // parameters. - for (String feedName : feedDefs.keySet()) { - Node n; - Node feedNode = feedDefs.get(feedName); - NodeList nodes = feedNode.getChildNodes(); + // Reading all attributes and making the substitution on them. + Map<String, String> attributes = Tools.getMapFromNodeAttributes(definition); + getSubstitution().make(attributes); - Set<String> feedRequirements = new HashSet<String>(); - requirements.put(feedName, feedRequirements); - parameters.put(feedName, new String[] { - XmlTools.getAttributeValue(feedNode, "title"), - XmlTools.getAttributeValue(feedNode, "description"), - XmlTools.getAttributeValue(feedNode, "author") }); - feedDisplayNames.put(feedName, XmlTools.getAttributeValue(feedNode, - "display-name")); + // First, getting (and if need be, generating) the feeds to be + // aggregated as written in the tag. + Set<Feed> toAggregate = new HashSet<Feed>(); + NodeList nodes = definition.getChildNodes(); + for (int i=0; i<nodes.getLength(); i++) { + Node n = nodes.item(i); + if ("include".equals(n.getNodeName())) { + String nameAttr = Tools.getAttributeValue(n, "name"); - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - if ("include".equals(n.getNodeName())) { - String nameAttr = XmlTools.getAttributeValue(n, "name"); + // Generating substitutions. + Set<String> variables = FeedTagHandlerManager.getVariablesForNode(n); + Set<Substitution> substitutions = Substitution.newEmptySubstitionsSet(); - String[] siteIds = getSiteIds(); - - for (String siteId : siteIds) { - feedRequirements.add(nameAttr.replace(SITE_PARAM, - siteId)); - } + for (String variable : new HashSet<String>(variables)) { + fd.getVariableResolverManager().instantiateVariableResolver(variable, definition). + expandSubstitutionsSet(variables, substitutions); } - } - } - while (requirements.size() > 0) { - int sizeBefore = requirements.size(); + for (Substitution s : substitutions) { + String name = s.make(nameAttr); + Feed f = fd.getFeed(name, feedType); - for (Iterator<String> iter = requirements.keySet().iterator(); iter - .hasNext();) { - String feedName = iter.next(); - Set<String> feedRequirements = requirements.get(feedName); - String[] feedParameters = parameters.get(feedName); - Set<String> types = null; + if (f == null) { + // Trying to generate the feed. + if (!fd.generateFeed(name)) { + log.error("Cannot find all aggregated feeds or feeds definitions " + + "cycle for feed " + feedName + "."); + return false; + } - // Checking if the all of this feed's requirements are met - // and if so, of what types it can consist. - boolean allRequirementsMet = true; - for (String requirement : feedRequirements) { - Map<String, Feed> feedTypes = feeds.get(requirement); - - if (feedTypes == null) { - // Missing feed - cannot create the aggregated one. - allRequirementsMet = false; - break; + // The feeds have been successfully generated. + f = fd.getFeed(name, feedType); } - // Intersecting the types set with the types of the current - // feed. - if (types == null) { - types = new HashSet<String>(); - types.addAll(feedTypes.keySet()); - } else - types.retainAll(feedTypes.keySet()); + toAggregate.add(f); } + } + } - if (!allRequirementsMet) - continue; + if (toAggregate.size() == 0) { + log.error("Nothing to aggregate in feed " + feedName + "."); + return false; + } - // Gathering the feed parts from which the new feed will be - // composed. - for (String type : types) { - List<Feed> requiredFeeds = new ArrayList<Feed>(); - for (String requirement : feedRequirements) { - requiredFeeds.add(feeds.get(requirement).get(type)); - } + Feed feed = FeedFactory.getNewFeed(feedName, attributes.get(Constants.DISP_NAME_ATTR), + feedType); - Feed newFeed = FeedFactory.getNewFeed(type); - try { - newFeed.generate(requiredFeeds.toArray(new Feed[0]), - feedParameters[0], feedParameters[1], - feedParameters[2], generateFeedLink(true, - feedName, type)); - } catch (Exception e) { - log.warn("Can't add aggregated feed " + feedName - + " : " + type + ".", e); - } + try { + feed.generate(toAggregate.toArray(new Feed[0]), + attributes.get("title"), attributes.get("description"), + attributes.get("author"), generateFeedLink(fd, true, feedName, feedType)); + } catch (IOException e) { + log.error("Can't add aggregated feed " + feedName + " : " + feedType + ".", e); + } - addFeed(feedName, type, newFeed); - } + fd.addFeed(feedName, feedType, feed); - iter.remove(); - } - - if (sizeBefore == requirements.size()) { - log.warn("Aggregation feed definitions cycle, or demanded " - + "feeds are not defined; unable to create feeds."); - return; - } - } + return true; } } Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandler.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandler.java 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandler.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -1,34 +1,32 @@ package org.jboss.shotoku.feeds.tag; import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.jboss.shotoku.tools.Tools; import org.jboss.shotoku.feeds.variables.Substitution; -import org.jboss.shotoku.feeds.data.Feed; -import org.jboss.shotoku.feeds.FeedFactory; import org.jboss.shotoku.feeds.FeedsDescriptor; +import org.jboss.shotoku.feeds.Constants; -import java.util.Map; -import java.util.Set; -import java.util.HashSet; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.net.URL; - /** + * A base class for classes which handle generation of various feed types, + * basing on feed description that is contained in an xml node. * @author Adam Warski (ad...@as...) */ public abstract class FeedTagHandler { + private String feedName; private String group; private Node definition; private Substitution s; - public FeedTagHandler(String group, Node definition, Substitution s) { + public FeedTagHandler(String feedName, String group, Node definition, Substitution s) { + this.feedName = feedName; this.group = group; this.definition = definition; this.s = s; } + public String getFeedName() { + return feedName; + } + public String getGroup() { return group; } @@ -41,14 +39,31 @@ return s; } + public String getFeedType() { + return s.getSubstitutionFor(Constants.TYPE_VARIABLE); + } + /** * Generates a feed handled by this instance. The generated feed should * be added to the FeedsDescriptor by calling the FeedsDescriptor.addFeed() * method. * @param fd - * @param duringGeneration A set of feed names that are being generated - * at the moment. * @return True iff the generation was successfull and the feed was added. */ - public abstract boolean generate(FeedsDescriptor fd, Set<String> duringGeneration); + public abstract boolean generate(FeedsDescriptor fd); + + /** + * Generates a link to a specified feed. If the link is to be full, an + * absolute address is returned. Otherwise, a relative one. + * @param fd + * @param full + * @param feedName + * @param feedType + * @return Link to the given feed. + */ + protected String generateFeedLink(FeedsDescriptor fd, boolean full, String feedName, + String feedType) { + return (full ? fd.getBaseServerAddress() : "") + "/feeds/" + feedName + "/" + + feedType; + } } 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-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/FeedTagHandlerManager.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -5,12 +5,11 @@ import org.jboss.shotoku.feeds.FeedsDescriptor; import org.jboss.shotoku.feeds.variables.VariableResolverManager; import org.jboss.shotoku.feeds.variables.Substitution; -import org.jboss.logging.Logger; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import org.apache.log4j.Logger; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.Map; import java.util.Set; import java.util.HashSet; @@ -22,16 +21,16 @@ * @author Adam Warski (ad...@as...) */ public class FeedTagHandlerManager { - private static final Logger log = Logger.getLogger(FeedTagHandlerManager.class); + private static final Logger log = Logger.getLogger(FeedsDescriptor.class); /** * Tag name -> tag handler constructor. */ - private static Map<String, Constructor> handlers; + private static final Map<String, Constructor> handlers; private static void addHandler(String tagName, Class handlerClass) { try { - handlers.put(tagName, handlerClass.getConstructor(String.class, Node.class, + handlers.put(tagName, handlerClass.getConstructor(String.class, String.class, Node.class, Substitution.class)); } catch (NoSuchMethodException e) { log.error("No (String, Node) constructor found in tag " + tagName + " handler " + @@ -40,6 +39,8 @@ } static { + handlers = new HashMap<String, Constructor>(); + addHandler(Constants.AGG_FEED_TAG, AggregatedFeedTagHandler.class); addHandler(Constants.REM_FEED_TAG, RemoteFeedTagHandler.class); addHandler(Constants.SHO_FEED_TAG, ShotokuFeedTagHandler.class); @@ -80,13 +81,13 @@ return variables; } - public static Map<String, FeedTagHandler> getHandlers(String group, Node definition, - VariableResolverManager vrm) { + public static void createHandlers(String group, Node definition, + VariableResolverManager vrm, FeedsDescriptor fd) { // 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 new HashMap<String, FeedTagHandler>(); + return; } // Reading the feed name attribute. @@ -108,20 +109,15 @@ feedNameAttr + "."); } - // Creating the map which will be returned. - Map<String, FeedTagHandler> ret = new HashMap<String, FeedTagHandler>(); - // For each substitution, adding a tag handler to FeedsDescriptor. for (Substitution s : substitutions) { String feedName = s.make(feedNameAttr); try { - ret.put(feedName, - (FeedTagHandler) handlerConstr.newInstance(group, definition, s)); + fd.addFeedTagHandler(feedName, s.getSubstitutionFor(Constants.TYPE_VARIABLE), + (FeedTagHandler) handlerConstr.newInstance(feedName, group, definition, s)); } catch (Exception e) { log.error("Error constructing feed " + feedName + " tag handler.", e); } } - - return ret; } } 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-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/RemoteFeedTagHandler.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -6,55 +6,40 @@ import org.jboss.shotoku.feeds.data.Feed; import org.jboss.shotoku.feeds.FeedFactory; import org.jboss.shotoku.feeds.Constants; +import org.jboss.shotoku.feeds.FeedsDescriptor; +import org.apache.log4j.Logger; -import java.util.Map; -import java.util.Set; -import java.util.HashSet; import java.net.URL; /** * @author Adam Warski (ad...@as...) */ public class RemoteFeedTagHandler extends FeedTagHandler { - public void generate(Map<String, FeedDefinition> feedDefs) { - for (String feedName : feedDefs.keySet()) { - FeedDefinition feedDefinition = feedDefs.get(feedName); - Node feedNode = feedDefinition.definition; + private static final Logger log = Logger.getLogger(FeedsDescriptor.class); - String addressAttr = Tools.getAttributeValue(feedNode, "address"); - String displayNameAttr = Tools.getAttributeValue(feedNode, "display-name"); + public RemoteFeedTagHandler(String feedName, String group, Node definition, Substitution s) { + super(feedName, group, definition, s); + } - Set<String> variables = new HashSet<String>(); - // We always have to substitute the type variable. - variables.add(Constants.TYPE_VARIABLE); - addVariablesFromNode(variables, feedNode); + public boolean generate(FeedsDescriptor fd) { + Substitution s = getSubstitution(); + String feedName = getFeedName(); + String feedType = getFeedType(); - Set<Substitution> substitutions = Substitution.newEmptySubstitionsSet(); + String address = s.make(Tools.getAttributeValue(getDefinition(), "address")); + String displayName = s.make(Tools.getAttributeValue(getDefinition(), + Constants.DISP_NAME_ATTR)); - for (String variable : new HashSet<String>(variables)) { - instantiateVariableResolver(variable, feedNode). - expandSubstitutionsSet(variables, substitutions); - } + try { + Feed feed = FeedFactory.getNewFeed(feedName, displayName, feedType); + feed.generate(new URL(address)); + fd.addFeed(feedName, feedType, feed); + } catch (Exception e) { + log.debug("Can't add feed " + address + " : " + feedType + ".", e); - if (variables.size() > 0) { - log.warn("Unresolved variables left: " + variables.toString() + " in feed " + - feedName + "."); - continue; - } - - for (Substitution s : substitutions) { - String feedNameSub = s.make(feedName); - String feedType = s.getSubstitutionFor(Constants.TYPE_VARIABLE); - try { - Feed feed = FeedFactory.getNewFeed(feedNameSub, - s.make(displayNameAttr), feedType); - feed.generate(new URL(s.make(addressAttr))); - addFeed(feedNameSub, feedType, feed); - } catch (Exception e) { - log.debug("Can't add feed " + s.make(addressAttr) + " : " + feedType - + ".", e); - } - } + return false; } + + return true; } } 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-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -2,18 +2,21 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.jboss.shotoku.search.SearchParameter; -import org.jboss.shotoku.search.Search; +import org.jboss.shotoku.search.*; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.tools.Tools; import org.jboss.shotoku.feeds.tools.RdfDateFormat; import org.jboss.shotoku.feeds.tools.TextEscaping; import org.jboss.shotoku.feeds.data.Feed; import org.jboss.shotoku.feeds.FeedFactory; +import org.jboss.shotoku.feeds.FeedsDescriptor; +import org.jboss.shotoku.feeds.Constants; +import org.jboss.shotoku.feeds.variables.Substitution; import org.apache.velocity.VelocityContext; +import org.apache.log4j.Logger; import java.util.*; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import java.lang.reflect.Constructor; import java.text.SimpleDateFormat; import java.io.Writer; @@ -21,181 +24,168 @@ * @author Adam Warski (ad...@as...) */ public class ShotokuFeedTagHandler extends FeedTagHandler { - public ShotokuFeedTagHandler(String group, Node definition) { - super(group, definition); + private static final Logger log = Logger.getLogger(FeedsDescriptor.class); + + public ShotokuFeedTagHandler(String feedName, String group, Node definition, Substitution s) { + super(feedName, group, definition, s); } + private static final Map<String, Constructor> paramsParametrized; + private static final Map<String, Constructor> paramsSimple; - /** - * Recursively generates a search parameter basing on its description that is - * contained in the given node. - * @param n Node from which to read the search parameters. - * @param props Properties with directives classes. - * @param parametrized Set of directive names that accept a parameter map - * in their constructor. - * @return A search parameter that is described in the given node. - * @throws IllegalArgumentException - * @throws SecurityException - * @throws InstantiationException - * @throws IllegalAccessException - * @throws java.lang.reflect.InvocationTargetException - * @throws NoSuchMethodException - * @throws ClassNotFoundException - */ - private SearchParameter generateSearchParameter(Node n, Properties props, - Set<String> parametrized, String siteId) - throws IllegalArgumentException, SecurityException, - InstantiationException, IllegalAccessException, - InvocationTargetException, NoSuchMethodException, - ClassNotFoundException { - String paramName = n.getNodeName(); + private static void addParamParametrized(String paramName, Class c) { + try { + paramsParametrized.put(paramName, c.getConstructor(Map.class)); + } catch (NoSuchMethodException e) { + log.error("Error adding a parametrized search parameter class " + + c.getName() + ".", e); + } + } - // Looking for a corresponding class. - String paramClass = props.getProperty(paramName); + private static void addParamSimple(String paramName, Class c) { + try { + paramsSimple.put(paramName, c.getConstructor()); + } catch (NoSuchMethodException e) { + log.error("Error adding a simple search parameter class " + + c.getName() + ".", e); + } + } - if (paramClass == null) - throw new RuntimeException("Unknown parameter name: " + paramName - + "."); + static { + paramsParametrized = new HashMap<String, Constructor>(); + paramsSimple = new HashMap<String, Constructor>(); - SearchParameter param; - if (parametrized.contains(paramName)) { - // Instatiating the class, it should have a constructor accepting a - // map. We take the map from node attributes, and replace - // ${site} and ${site-name} in them. - param = (SearchParameter) Class.forName(paramClass).getConstructor( - new Class[] { Map.class }).newInstance( - new Object[] { replaceInMapValues(replaceInMapValues( - XmlTools.getMapFromNodeAttributes(n), - SITE_PARAM, siteId), SITE_NAME_PARAM, - getSiteName(siteId)) }); - } else { - param = (SearchParameter) Class.forName(paramClass).newInstance(); - } + addParamSimple("and", AndNodeFilter.class); + addParamSimple("or", OrNodeFilter.class); + addParamSimple("property-value", PropertyValueParameter.class); - NodeList nodeList = n.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node child = nodeList.item(i); + addParamSimple("search", Search.class); + addParamSimple("shotoku-feed", Search.class); - if (child.getNodeType() == Node.ELEMENT_NODE) { - // If the search paramater has child nodes, then the - // corresponding class should have an "add" method. - // Invoking the function recursively and adding the - // resulting parameter. - SearchParameter childParam = generateSearchParameter(child, - props, parametrized, siteId); + addParamParametrized("directory", DirectoryIncludeParameter.class); + addParamParametrized("history", HistoryIncludeParameter.class); + addParamParametrized("limit", LimitParameter.class); + addParamParametrized("property-sort", PropertySortParameter.class); + addParamParametrized("date-sort", DateSortParameter.class); + } - Method[] methods = param.getClass().getMethods(); - for (Method method : methods) { - if ("add".equals(method.getName())) { - method.invoke(param, new Object[] { childParam }); - break; - } - } - } - } + /** + * Recursively generates a search parameter basing on its description that is + * contained in the given node. + * @param n Node from which to read the search parameters. + * @return A search parameter that is described in the given node. + * @throws Exception + */ + private SearchParameter generateSearchParameter(Node n) + throws Exception { + String paramName = n.getNodeName(); - return param; + SearchParameter param; + if (paramsParametrized.containsKey(paramName)) { + // We take the map from node attributes, and replace any variables in them. + Map<String, String> attrs = Tools.getMapFromNodeAttributes(n); + getSubstitution().make(attrs); + param = (SearchParameter) paramsParametrized.get(paramName).newInstance(attrs); + } else { + param = (SearchParameter) paramsSimple.get(paramName).newInstance(); } - private final static String RFC_822_DATE = "EEE, d MMM yyyy HH:mm:ss Z"; + NodeList nodeList = n.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node child = nodeList.item(i); - private void generateShotokuFeeds(Map<String, Node> feedDefs, - Properties props) { - Set<String> parametrized = new HashSet<String>(Arrays.asList(props.getProperty( - "parametrized").split("[,]"))); + if (child.getNodeType() == Node.ELEMENT_NODE) { + // If the search parameter has child nodes, then the + // corresponding class should have an "add" method. + // Invoking the function recursively and adding the + // resulting parameter. + SearchParameter childParam = generateSearchParameter(child); - for (String feedName : feedDefs.keySet()) { - Node feedNode = feedDefs.get(feedName); - String templateAttr = XmlTools.getAttributeValue(feedNode, - "template"); - String prefixAttr = XmlTools.getAttributeValue(feedNode, "prefix"); - String idAttr = XmlTools.getAttributeValue(feedNode, "id"); - String typesAttr = XmlTools.getAttributeValue(feedNode, "type"); - String displayNameAttr = XmlTools.getAttributeValue(feedNode, - "display-name"); + param.getClass().getMethod("add", SearchParameter.class).invoke(param, childParam); + } + } - ContentManager cm = ContentManager.getContentManager(idAttr, - prefixAttr); + return param; + } - // Generating the type of feeds that have been requested. - String[] types = getTypes(typesAttr); - // Generating the sites for which the feeds have been requested, - // if any. - String[] siteIds = getSiteIds(); + private final static String RFC_822_DATE = "EEE, d MMM yyyy HH:mm:ss Z"; - Map<String, String> attributes = XmlTools - .getMapFromNodeAttributes(feedNode); + public boolean generate(FeedsDescriptor fd) { + Node definition = getDefinition(); + Substitution s = getSubstitution(); - // Creating a velcoity context with parts that won't change in all - // generated feeds. - VelocityContext vc = new VelocityContext(attributes); + // Reading all attributes and making the substitution on them. + Map<String, String> attributes = Tools.getMapFromNodeAttributes(definition); + s.make(attributes); - String dateFormat = attributes.get("dateFormat"); - vc.put("dateFormat", new SimpleDateFormat( - dateFormat == null ? "MM/dd/yy" : dateFormat)); - vc.put("rssDateFormat", new SimpleDateFormat(RFC_822_DATE)); - vc.put("rdfDateFormat", new RdfDateFormat()); - vc.put("now", Calendar.getInstance().getTime()); - vc.put("baseServerAddress", baseServerAddress); - vc.put("escape", new TextEscaping()); + String template = attributes.get("template"); + String displayName = attributes.get(Constants.DISP_NAME_ATTR); - for (String site : siteIds) { - String feedNameReplaced = feedName.replace(SITE_PARAM, - site); + ContentManager cm = ContentManager.getContentManager(attributes.get("id"), + attributes.get("prefix")); - NodeList feedNodeChildren = feedNode.getChildNodes(); - for (int i = 0; i < feedNodeChildren.getLength(); i++) { - // For each search node, generating and performing the - // search, placing it under the demanded attribute in - // velocity's context. - Node searchNode = feedNodeChildren.item(i); - if ("search".equals(searchNode.getNodeName())) { - try { - Search search = (Search) generateSearchParameter( - searchNode, props, parametrized, site); + // Creating a velocity context with parts that won't change in all + // generated feeds. + VelocityContext vc = new VelocityContext(attributes); - org.jboss.shotoku.NodeList list = cm.search(search); + String dateFormat = attributes.get("dateFormat"); + vc.put("dateFormat", new SimpleDateFormat(dateFormat == null ? "MM/dd/yy" : dateFormat)); + vc.put("rssDateFormat", new SimpleDateFormat(RFC_822_DATE)); + vc.put("rdfDateFormat", new RdfDateFormat()); + vc.put("now", Calendar.getInstance().getTime()); + vc.put("baseServerAddress", fd.getBaseServerAddress()); + vc.put("escape", new TextEscaping()); - String searchNameAttr = XmlTools.getAttributeValue( - searchNode, "name"); - if (searchNameAttr == null) - searchNameAttr = "nodes"; + NodeList feedNodeChildren = definition.getChildNodes(); + for (int i = 0; i < feedNodeChildren.getLength(); i++) { + // For each search node, generating and performing the + // search, placing it under the demanded attribute in + // velocity's context. + Node searchNode = feedNodeChildren.item(i); + if ("search".equals(searchNode.getNodeName())) { + try { + Search search = (Search) generateSearchParameter( + searchNode); - vc.put(searchNameAttr, list); - } catch (Exception e) { - log.warn("Error generating shotoku feed " - + feedName + ".", e); - continue; - } - } + org.jboss.shotoku.NodeList list = cm.search(search); + + String searchNameAttr = Tools.getAttributeValue(searchNode, "name"); + if (searchNameAttr == null) { + searchNameAttr = "nodes"; } - for (String type : types) { - String template = templateAttr.replace(TYPE_PARAM, type); + vc.put(searchNameAttr, list); + } catch (Exception e) { + log.error("Error generating shotoku feed " + getFeedName() + ".", e); - Feed newFeed = FeedFactory.getNewFeed(type); - try { - vc.put("link", generateFeedLink(true, feedNameReplaced, - type)); - - // Now that we have type and site, we can render the - // template. - Writer w = newFeed.getWriter(); - cm.getVelocityEngine().mergeTemplate(template, vc, w); - w.flush(); - w.close(); - - // And add the feed. - addFeed(feedNameReplaced, type, newFeed); - } catch (Exception e) { - log.warn("Cannot merge template " + template + " for " - + feedName + ".", e); - continue; - } - } + return false; } } } + String feedName = getFeedName(); + String feedType = getFeedType(); + Feed newFeed = FeedFactory.getNewFeed(feedName, displayName, feedType); + try { + vc.put("link", generateFeedLink(fd, true, feedName, feedType)); + + // Now that we have type and site, we can render the + // template. + Writer w = newFeed.getWriter(); + cm.getVelocityEngine().mergeTemplate(template, vc, w); + w.flush(); + w.close(); + + // And add the feed. + fd.addFeed(feedName, feedType, newFeed); + } catch (Exception e) { + log.error("Cannot merge template " + template + " for " + + feedName + ".", e); + + return false; + } + + return true; + } } 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-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/Substitution.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -50,6 +50,15 @@ return result.toString(); } + /** + * Makes the substitution in each value of the given map. + */ + public void make(Map<? extends Object, String> m) { + for (Map.Entry<? extends Object, String> e : m.entrySet()) { + e.setValue(make(e.getValue())); + } + } + @Override public Substitution clone() { Substitution ret; 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-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/variables/VariableResolverManager.java 2006-05-17 22:12:56 UTC (rev 4292) @@ -2,7 +2,8 @@ import org.w3c.dom.Node; import org.jboss.shotoku.feeds.Constants; -import org.jboss.logging.Logger; +import org.jboss.shotoku.feeds.FeedsDescriptor; +import org.apache.log4j.Logger; import java.util.HashMap; import java.util.Map; @@ -13,7 +14,7 @@ * @author Adam Warski (ad...@as...) */ public class VariableResolverManager { - private static final Logger log = Logger.getLogger(VariableResolverManager.class); + private static final Logger log = Logger.getLogger(FeedsDescriptor.class); private Map<String, Constructor> varResolversNodeConstructor; private Map<String, Constructor> varResolversEmptyConstructor; @@ -63,7 +64,7 @@ } c = varResolversEmptyConstructor.get(variable); - + if (c != null) { try { return (VariableResolver) c.newInstance(); Deleted: labs/shotoku/trunk/shotoku-feeds/src/web/WEB-INF/tld/forge.tld =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/web/WEB-INF/tld/forge.tld 2006-05-17 21:39:20 UTC (rev 4291) +++ labs/shotoku/trunk/shotoku-feeds/src/web/WEB-INF/tld/forge.tld 2006-05-17 22:12:56 UTC (rev 4292) @@ -1,139 +0,0 @@ -<taglib xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd" - version="2.0"> - <!-- - JBoss, the OpenSource J2EE webOS - Distributable under LGPL license. - See terms of license at gnu.org. - --> - <tlib-version>1.1</tlib-version> - <jsp-version>2.0</jsp-version> - <shortname>forge</shortname> - <info>Forge tags</info> - - <tag> - <name>pageURL</name> - <tagclass>org.jboss.forge.common.taglib.PageURLTag</tagclass> - <attribute> - <name>page</name> - ... [truncated message content] |