src/org/sonews/storage/Storage.java
author František Kučera <franta-hg@frantovo.cz>
Sun Nov 06 00:08:05 2011 +0100 (2011-11-06)
changeset 116 4ddc1020a154
parent 48 b78e77619152
permissions -rwxr-xr-x
Podpora Markdown syntaxe
na začátek odesílané zprávy stačí přidat:
#!markdown
a zpráva se pak prožene Markdown procesorem (spouštěno přes sudo pod jiným uživatelem)
a pak teprve přes standardní XSL transformaci.

1) Vytvořit uživatele a skupinu markdown

2) Do /etc/sudoers přidat:
Cmnd_Alias MARKDOWN = /usr/bin/markdown
%markdown ALL = (%markdown) NOPASSWD : MARKDOWN

3) Uivatele, pod kterým běží NNTP démon, přidat do skupiny markdown
     1 /*
     2  *   SONEWS News Server
     3  *   see AUTHORS for the list of contributors
     4  *
     5  *   This program is free software: you can redistribute it and/or modify
     6  *   it under the terms of the GNU General Public License as published by
     7  *   the Free Software Foundation, either version 3 of the License, or
     8  *   (at your option) any later version.
     9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 package org.sonews.storage;
    19 
    20 import java.util.List;
    21 import org.sonews.feed.Subscription;
    22 import org.sonews.util.Pair;
    23 
    24 /**
    25  * A generic storage backend interface.
    26  * @author Christian Lins
    27  * @since sonews/1.0
    28  */
    29 public interface Storage {
    30 
    31 	/**
    32 	 * Stores the given Article in the storage.
    33 	 * @param art
    34 	 * @throws StorageBackendException
    35 	 */
    36 	void addArticle(Article art)
    37 			throws StorageBackendException;
    38 
    39 	void addEvent(long timestamp, int type, long groupID)
    40 			throws StorageBackendException;
    41 
    42 	void addGroup(String groupname, int flags)
    43 			throws StorageBackendException;
    44 
    45 	int countArticles()
    46 			throws StorageBackendException;
    47 
    48 	int countGroups()
    49 			throws StorageBackendException;
    50 
    51 	void delete(String messageID)
    52 			throws StorageBackendException;
    53 
    54 	Article getArticle(String messageID)
    55 			throws StorageBackendException;
    56 
    57 	Article getArticle(long articleIndex, long groupID)
    58 			throws StorageBackendException;
    59 
    60 	List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
    61 			throws StorageBackendException;
    62 
    63 	List<Pair<Long, String>> getArticleHeaders(Group group, long start, long end,
    64 			String header, String pattern)
    65 			throws StorageBackendException;
    66 
    67 	long getArticleIndex(Article art, Group group)
    68 			throws StorageBackendException;
    69 
    70 	List<Long> getArticleNumbers(long groupID)
    71 			throws StorageBackendException;
    72 
    73 	String getConfigValue(String key)
    74 			throws StorageBackendException;
    75 
    76 	int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
    77 			Group group)
    78 			throws StorageBackendException;
    79 
    80 	double getEventsPerHour(int key, long gid)
    81 			throws StorageBackendException;
    82 
    83 	int getFirstArticleNumber(Group group)
    84 			throws StorageBackendException;
    85 
    86 	Group getGroup(String name)
    87 			throws StorageBackendException;
    88 
    89 	List<Group> getGroups()
    90 			throws StorageBackendException;
    91 
    92 	/**
    93 	 * Retrieves the collection of groupnames that are associated with the
    94 	 * given list address.
    95 	 * @param inetaddress
    96 	 * @return
    97 	 * @throws StorageBackendException
    98 	 */
    99 	List<String> getGroupsForList(String listAddress)
   100 			throws StorageBackendException;
   101 
   102 	int getLastArticleNumber(Group group)
   103 			throws StorageBackendException;
   104 
   105 	/**
   106 	 * Returns a list of email addresses that are related to the given
   107 	 * groupname. In most cases the list may contain only one entry.
   108 	 * @param groupname
   109 	 * @return
   110 	 * @throws StorageBackendException
   111 	 */
   112 	List<String> getListsForGroup(String groupname)
   113 			throws StorageBackendException;
   114 
   115 	String getOldestArticle()
   116 			throws StorageBackendException;
   117 
   118 	int getPostingsCount(String groupname)
   119 			throws StorageBackendException;
   120 
   121 	List<Subscription> getSubscriptions(int type)
   122 			throws StorageBackendException;
   123 
   124 	boolean isArticleExisting(String messageID)
   125 			throws StorageBackendException;
   126 
   127 	boolean isGroupExisting(String groupname)
   128 			throws StorageBackendException;
   129 
   130 	void purgeGroup(Group group)
   131 			throws StorageBackendException;
   132 
   133 	void setConfigValue(String key, String value)
   134 			throws StorageBackendException;
   135 
   136 	/**
   137 	 * Updates headers and channel references of the given article.
   138 	 * @param article
   139 	 * @return
   140 	 * @throws StorageBackendException
   141 	 */
   142 	boolean update(Article article)
   143 			throws StorageBackendException;
   144 
   145 	boolean update(Group group)
   146 			throws StorageBackendException;
   147 
   148 	public boolean authenticateUser(String username, char[] password)
   149 			throws StorageBackendException;
   150 }