protected Map<String, String> getParameterDescriptionsInternal() { Map<String, String> map = new LinkedHashMap<String, String>(); map.put(PARAMETER_ITEM_PICTURE, PARAMETER_ITEM_PICTURE_DESC); map.put(PARAMETER_IF_EMPTY_MESSAGE, PARAMETER_IF_EMPTY_MESSAGE_DESC); map.put(PARAMETER_FEED_ELEMENT_ORDER, PARAMETER_FEED_ELEMENT_ORDER_DESC); map.put(Parameter.URLS.getId(), Parameter.URLS.getDesc()); map.put(Parameter.FEED_TITLE.getId(), Parameter.FEED_TITLE.getDesc()); map.put(Parameter.MAX_MESSAGES.getId(), Parameter.MAX_MESSAGES.getDesc()); map.put(Parameter.DISPLAY_CHANNEL.getId(), Parameter.DISPLAY_CHANNEL.getDesc()); map.put(Parameter.ITEM_DESCRIPTION.getId(), Parameter.ITEM_DESCRIPTION.getDesc()); map.put(Parameter.PUBLISHED_DATE.getId(), Parameter.PUBLISHED_DATE.getDesc()); map.put(Parameter.SORT.getId(), Parameter.SORT.getDesc()); map.put(Parameter.INCLUDE_IF_EMPTY.getId(), Parameter.INCLUDE_IF_EMPTY.getDesc()); map.put(Parameter.DISPLAY_CATEGORIES.getId(), Parameter.DISPLAY_CATEGORIES.getDesc()); map.put(PARAMETER_ALLOW_MARKUP, PARAMETER_ALLOW_MARKUP_DESC); return map; }
@Override protected void processModel( Map<String, Object> model, DecoratorRequest request, DecoratorResponse response) throws Exception { super.processModel(model, request, response); Map<String, Object> conf = new HashMap<String, Object>(); String urls = request.getStringParameter(Parameter.URLS.getId()); if (urls == null) { throw new DecoratorComponentException("Component parameter 'urls' is required"); } String feedTitle = request.getStringParameter(Parameter.FEED_TITLE.getId()); if (feedTitle != null) { conf.put("feedTitleValue", feedTitle.trim()); } if (parameterHasValue(PARAMETER_ITEM_PICTURE, "true", request)) { conf.put("itemPicture", true); } if (!parameterHasValue(Parameter.DISPLAY_CHANNEL.getId(), "false", request)) { conf.put("displayChannel", true); } if (parameterHasValue(Parameter.ITEM_DESCRIPTION.getId(), "true", request)) { conf.put("itemDescription", true); } conf.put("maxMsgs", 10); String maxMsgsString = request.getStringParameter(Parameter.MAX_MESSAGES.getId()); if (maxMsgsString != null) { try { int tmpInt = Integer.parseInt(maxMsgsString); if (tmpInt > 0) { conf.put("maxMsgs", tmpInt); } } catch (Exception e) { } } String publishedDateString = request.getStringParameter(Parameter.PUBLISHED_DATE.getId()); if ("none".equals(publishedDateString)) { conf.put("publishedDate", null); } else if ("date".equals(publishedDateString)) { conf.put("publishedDate", "short"); } else { conf.put("publishedDate", "long"); } // Typical sort strings we handle: // asc // item-title // item-title desc // desc item-title // etc.. String sortString = request.getStringParameter(Parameter.SORT.getId()); // Indicates explicitly set sort direction boolean directionSpecified = false; if (sortString != null) { StringTokenizer tokenizer = new StringTokenizer(sortString); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if ("item-title".equals(token)) { conf.put("sortByTitle", true); if (!directionSpecified) { // Set to default for title, if not already specified. conf.put("sortAscending", true); } } else if ("asc".equalsIgnoreCase(token)) { conf.put("sortAscending", true); directionSpecified = true; } else if ("desc".equalsIgnoreCase(token)) { conf.remove("sortAscending"); directionSpecified = true; } } } boolean includeIfEmpty = true; String includeIfEmptyParam = request.getStringParameter(Parameter.INCLUDE_IF_EMPTY.getId()); if ("false".equalsIgnoreCase(includeIfEmptyParam)) { includeIfEmpty = false; } conf.put("includeIfEmpty", includeIfEmpty); String displayCategoriesParam = request.getStringParameter(Parameter.DISPLAY_CATEGORIES.getId()); if (displayCategoriesParam != null && "true".equalsIgnoreCase(displayCategoriesParam)) { conf.put("displayCategories", true); } SyndFeed feed = new SyndFeedImpl(); feed.setTitle("Aggregated Feed"); feed.setDescription("Vortex Aggregated Feed"); feed.setAuthor("Vortex"); feed.setLink("http://www.uio.no"); List<SyndEntry> entries = new ArrayList<SyndEntry>(); feed.setEntries(entries); Map<SyndEntry, SyndFeed> feedMapping = new HashMap<SyndEntry, SyndFeed>(); boolean displayChannel = conf.get("displayChannel") != null && (Boolean) conf.get("displayChannel"); if (displayChannel) { model.put("feedMapping", new FeedMapping(feedMapping)); } URL requestURL = RequestContext.getRequestContext().getRequestURL(); String[] urlArray = urls.split(","); Map<String, String> imgMap = new HashMap<String, String>(); Map<String, String> descriptionNoImage = new HashMap<String, String>(); parseFeeds(request, entries, feedMapping, imgMap, descriptionNoImage, requestURL, urlArray); try { sort(entries); } catch (MissingPublishedDateException e) { SyndFeed f = feedMapping.get(e.getEntry()); throw new MissingPublishedDateException( "Unable to sort feed '" + f.getUri() + "': does not contain published date"); } List<String> elementOrder = getElementOrder(PARAMETER_FEED_ELEMENT_ORDER, request); model.put("elementOrder", elementOrder); model.put("descriptionNoImage", descriptionNoImage); model.put("imageMap", imgMap); String displayIfEmptyMessage = request.getStringParameter(PARAMETER_IF_EMPTY_MESSAGE); if (displayIfEmptyMessage != null && displayIfEmptyMessage.length() > 0) { model.put("displayIfEmptyMessage", displayIfEmptyMessage); } /* Temp fix for auth variable in ftl. */ conf.put("auth", true); model.put("feed", feed); model.put("conf", conf); }