|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MultiBlog | Line # 51 | 32 | 0% | 11 | 9 | 80,4% |
0.8043478
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (8) | |||
| Result | |||
|
0.3478261
|
net.sourceforge.pebble.web.filter.MultiBlogTransformingFilterTest.testUriInsertedIntoRequestScope
net.sourceforge.pebble.web.filter.MultiBlogTransformingFilterTest.testUriInsertedIntoRequestScope
|
1 PASS | |
|
0.3478261
|
net.sourceforge.pebble.web.filter.MultiBlogTransformingFilterTest.testUriInsertedIntoRequestScope
net.sourceforge.pebble.web.filter.MultiBlogTransformingFilterTest.testUriInsertedIntoRequestScope
|
1 PASS | |
|
0.3478261
|
net.sourceforge.pebble.web.filter.MultiBlogBlogLookupFilterTest.testBlogInsertedIntoRequestScope
net.sourceforge.pebble.web.filter.MultiBlogBlogLookupFilterTest.testBlogInsertedIntoRequestScope
|
1 PASS | |
|
0.3478261
|
net.sourceforge.pebble.web.filter.MultiBlogBlogLookupFilterTest.testBlogInsertedIntoRequestScope
net.sourceforge.pebble.web.filter.MultiBlogBlogLookupFilterTest.testBlogInsertedIntoRequestScope
|
1 PASS | |
|
0.2826087
|
net.sourceforge.pebble.domain.MultiBlogTest.testLastModified
net.sourceforge.pebble.domain.MultiBlogTest.testLastModified
|
1 PASS | |
|
0.2826087
|
net.sourceforge.pebble.domain.MultiBlogTest.testLastModified
net.sourceforge.pebble.domain.MultiBlogTest.testLastModified
|
1 PASS | |
|
0.17391305
|
net.sourceforge.pebble.domain.MultiBlogTest.testRecentBlogEntries
net.sourceforge.pebble.domain.MultiBlogTest.testRecentBlogEntries
|
1 PASS | |
|
0.17391305
|
net.sourceforge.pebble.domain.MultiBlogTest.testRecentBlogEntries
net.sourceforge.pebble.domain.MultiBlogTest.testRecentBlogEntries
|
1 PASS | |
| 1 | /* | |
| 2 | * Copyright (c) 2003-2006, Simon Brown | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions are met: | |
| 7 | * | |
| 8 | * - Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * | |
| 11 | * - Redistributions in binary form must reproduce the above copyright | |
| 12 | * notice, this list of conditions and the following disclaimer in | |
| 13 | * the documentation and/or other materials provided with the | |
| 14 | * distribution. | |
| 15 | * | |
| 16 | * - Neither the name of Pebble nor the names of its contributors may | |
| 17 | * be used to endorse or promote products derived from this software | |
| 18 | * without specific prior written permission. | |
| 19 | * | |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | */ | |
| 32 | package net.sourceforge.pebble.domain; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.comparator.BlogEntryComparator; | |
| 35 | import net.sourceforge.pebble.PebbleContext; | |
| 36 | ||
| 37 | import javax.servlet.http.HttpServletRequest; | |
| 38 | import java.util.*; | |
| 39 | ||
| 40 | /** | |
| 41 | * A composite blog is one that is made up of one or more simple blogs. This | |
| 42 | * is effectively a container when Pebble is running in multi-user mode - there | |
| 43 | * being a single MultiBlog and many Blog instances. | |
| 44 | * <br /><br /> | |
| 45 | * In addition to managing one or more simple blogs, a composite blog provides | |
| 46 | * some aggegration functionality over the blogs it manages in order to | |
| 47 | * generate an aggregated XML (RSS/RDF/Atom) feed. | |
| 48 | * | |
| 49 | * @author Simon Brown | |
| 50 | */ | |
| 51 | public class MultiBlog extends AbstractBlog { | |
| 52 | ||
| 53 | /** | |
| 54 | * Creates a new Blog instance, based at the specified location. | |
| 55 | * | |
| 56 | * @param root an absolute path pointing to the root directory of the blog | |
| 57 | */ | |
| 58 | 10 |
public MultiBlog(String root) { |
| 59 | 10 | super(root); |
| 60 | ||
| 61 | // probably MultiBlog should be made a final class if init is called from here - | |
| 62 | // see javadoc comment on AbstractBlog.init() for reasons | |
| 63 | 10 | init(); |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Gets the default properties for a MultiBlog. | |
| 68 | * | |
| 69 | * @return a Properties instance | |
| 70 | */ | |
| 71 | 10 |
protected Properties getDefaultProperties() { |
| 72 | 10 | Properties defaultProperties = new Properties(); |
| 73 | 10 | defaultProperties.setProperty(NAME_KEY, "My blogs"); |
| 74 | 10 | defaultProperties.setProperty(DESCRIPTION_KEY, ""); |
| 75 | 10 | defaultProperties.setProperty(IMAGE_KEY, ""); |
| 76 | 10 | defaultProperties.setProperty(AUTHOR_KEY, "Various"); |
| 77 | 10 | defaultProperties.setProperty(TIMEZONE_KEY, "Europe/London"); |
| 78 | 10 | defaultProperties.setProperty(RECENT_BLOG_ENTRIES_ON_HOME_PAGE_KEY, "3"); |
| 79 | 10 | defaultProperties.setProperty(LANGUAGE_KEY, "en"); |
| 80 | 10 | defaultProperties.setProperty(COUNTRY_KEY, "GB"); |
| 81 | 10 | defaultProperties.setProperty(CHARACTER_ENCODING_KEY, "UTF-8"); |
| 82 | 10 | defaultProperties.setProperty(THEME_KEY, "default"); |
| 83 | ||
| 84 | 10 | return defaultProperties; |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Gets the ID of this blog. | |
| 89 | * | |
| 90 | * @return the ID as a String | |
| 91 | */ | |
| 92 | 0 |
public String getId() { |
| 93 | 0 | return ""; |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * Gets the URL where this blog is deployed. | |
| 98 | * | |
| 99 | * @return a URL as a String | |
| 100 | */ | |
| 101 | 0 |
public String getUrl() { |
| 102 | 0 | return PebbleContext.getInstance().getConfiguration().getUrl(); |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Gets the relative URL where this blog is deployed. | |
| 107 | * | |
| 108 | * @return a URL as a String | |
| 109 | */ | |
| 110 | 0 |
public String getRelativeUrl() { |
| 111 | 0 | return "/"; |
| 112 | } | |
| 113 | ||
| 114 | /** | |
| 115 | * Gets the date that this blog was last updated. | |
| 116 | * | |
| 117 | * @return a Date instance representing the time of the most recent entry | |
| 118 | */ | |
| 119 | 4 |
public Date getLastModified() { |
| 120 | 4 | Date date = new Date(0); |
| 121 | ||
| 122 | 4 | Iterator it = BlogManager.getInstance().getPublicBlogs().iterator(); |
| 123 | 4 | Blog blog; |
| 124 | 12 | while (it.hasNext()) { |
| 125 | 8 | blog = (Blog)it.next(); |
| 126 | 8 | if (blog.getLastModified().after(date)) { |
| 127 | 2 | date = blog.getLastModified(); |
| 128 | } | |
| 129 | } | |
| 130 | ||
| 131 | 4 | return date; |
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * Gets the most recent blog entries, the number | |
| 136 | * of which is specified. | |
| 137 | * | |
| 138 | * @param numberOfEntries the number of entries to get | |
| 139 | * @return a List containing the most recent blog entries | |
| 140 | */ | |
| 141 | 6 |
public List getRecentBlogEntries(int numberOfEntries) { |
| 142 | 6 | List blogEntries = new ArrayList(); |
| 143 | ||
| 144 | 6 | for (Blog blog : BlogManager.getInstance().getPublicBlogs()) { |
| 145 | 12 | blogEntries.addAll(blog.getRecentPublishedBlogEntries()); |
| 146 | } | |
| 147 | ||
| 148 | 6 | Collections.sort(blogEntries, new BlogEntryComparator()); |
| 149 | ||
| 150 | 6 | if (blogEntries.size() >= numberOfEntries) { |
| 151 | 6 | return new ArrayList(blogEntries).subList(0, numberOfEntries); |
| 152 | } else { | |
| 153 | 0 | return new ArrayList(blogEntries); |
| 154 | } | |
| 155 | } | |
| 156 | ||
| 157 | /** | |
| 158 | * Logs this request for blog. | |
| 159 | * | |
| 160 | * @param request the HttpServletRequest instance for this request | |
| 161 | */ | |
| 162 | 0 |
public void log(HttpServletRequest request, int status) { |
| 163 | // no op | |
| 164 | } | |
| 165 | ||
| 166 | } | |
|
||||||||||||