1 /***************************************************************** 2 * Licensed to the Apache Software Foundation (ASF) under one * 3 * or more contributor license agreements. See the NOTICE file * 4 * distributed with this work for additional information * 5 * regarding copyright ownership. The ASF licenses this file * 6 * to you under the Apache License, Version 2.0 (the * 7 * "License"); you may not use this file except in compliance * 8 * with the License. You may obtain a copy of the License at * 9 * * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, * 13 * software distributed under the License is distributed on an * 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 15 * KIND, either express or implied. See the License for the * 16 * specific language governing permissions and limitations * 17 * under the License. * 18 ****************************************************************/ 19 20 package org.apache.james.nntpserver.repository; 21 22 import java.io.InputStream; 23 import java.io.IOException; 24 import java.util.Date; 25 import java.util.Iterator; 26 27 /*** 28 * Contract exposed by a NewsGroup 29 * 30 */ 31 public interface NNTPGroup { 32 33 /*** 34 * Gets the name of the newsgroup 35 * 36 * @return the newsgroup name 37 */ 38 String getName(); 39 40 /*** 41 * Gets the description of the newsgroup 42 * 43 * @return the newsgroup description 44 */ 45 String getDescription(); 46 47 /*** 48 * Returns whether posting is allowed to this newsgroup 49 * 50 * @return whether posting is allowed to this newsgroup 51 */ 52 boolean isPostAllowed(); 53 54 /*** 55 * Gets the number of articles in the group. 56 * 57 * @return the number of articles in the group. 58 */ 59 int getNumberOfArticles(); 60 61 /*** 62 * Gets the first article number in the group. 63 * 64 * @return the first article number in the group. 65 */ 66 int getFirstArticleNumber(); 67 68 /*** 69 * Gets the last article number in the group. 70 * 71 * @return the last article number in the group. 72 */ 73 int getLastArticleNumber(); 74 75 /*** 76 * Gets the article with the specified article number. 77 * 78 * @param number the article number 79 * 80 * @return the article 81 */ 82 NNTPArticle getArticle(int number); 83 84 /*** 85 * Retrieves an iterator of articles in this newsgroup that were 86 * posted on or after the specified date. 87 * 88 * @param dt the Date that acts as a lower bound for the list of 89 * articles 90 * 91 * @return the article iterator 92 */ 93 Iterator getArticlesSince(Date dt); 94 95 /*** 96 * Retrieves an iterator of all articles in this newsgroup 97 * 98 * @return the article iterator 99 */ 100 Iterator getArticles(); 101 102 /*** 103 * Retrieves the group information in a format consistent with 104 * a LIST or LIST ACTIVE return line 105 * 106 * @return the properly formatted string 107 */ 108 String getListFormat(); 109 110 /*** 111 * Retrieves the group information in a format consistent with 112 * a LIST NEWSGROUPS return line 113 * 114 * @return the properly formatted string 115 */ 116 String getListNewsgroupsFormat(); 117 118 /*** 119 * Adds an article to the group based on the data in the 120 * stream. 121 * 122 * @param newsStream the InputStream containing the article data 123 * 124 * @return the newly created article 125 */ 126 NNTPArticle addArticle(InputStream newsStream) throws IOException; 127 }