package org.pegadi.server; import no.dusken.common.model.Person; import org.pegadi.model.Article; import org.pegadi.sqlsearch.SearchTerm; import java.io.File; import java.util.List; /** * @author Marvin B. Lillehaug <lillehau@underdusken.no> */ public interface ArticleServer { public boolean canEdit(Person person, int artId); public boolean canDelete(Person person, int artID); public List<Article> getArticlesBySearchTerm(SearchTerm searchTerm); public List<Article> getArticlesBySearchTerm(Person person, SearchTerm searchTerm); public List<Article> getArticlesBySearchTerm(SearchTerm searchTerm, Integer count, Integer offset); /** * Saves a new or updates an existing article. If the articleID is 0, a new article is inserted into the database * and the new ID is returned. Else the article will be updated. This method will not save or modyify * the article text. The exception is when the article type changes. * * @param article The article to save. * @return New articleID if new article is created or 0 for successful save of existing article. Returnvalue less than 0 * means that something was wrong, and the article was not successfully saved. */ public int saveArticle(Article article); /** * Save the text of an open article. * * @param article The article. * @return true if successful. */ public boolean saveArticleText(Article article); /** * Returns the article with the given ID. * The fields in article which are not set, have a <code>null</code> value. * The text of the article is parsed if the argument <code>parse</code> is true * * @param person The user requesting this article. * @param ID the id of the article wanted. * @return Article The article. If the article has articlestatus hidden it will only be returned if * it is owned by the user that has userID */ public Article getArticleByID(Person person, int ID); public Article getArticleByID(int ID); public List<Article> getArticlesByPageID(int pageId); public List<Article> getArticlesByDispID(int dispId); /** * Returns the template for the given article. This method will return * <code>null</code> if the template isn't found or an exception is thrown. * TODO: This method does not consider the encoding of the template XML. * The proper way to fix this is to parse as XML, and then serialize. * * @param articleID The ID of the article. * @return The template. */ public String getTemplate(int articleID); /** * Returns an array of users who are allowed to edit a given article, excluding the owner of the article * * @param articleID The ID for the article to get a list of allowed users for. * @return An array of <code>User</code>s who are allowed to edit the article */ public List<Person> getCoJournalistsForArticle(int articleID); /** * Sets the users allowed to edit a given article, excluding the owner. Note that all the previous co-journalists * who was set, is erased before the new ones are saved. * * @param articleID The article to grant access to. * @param coJournalists The userIDs for the users allowed to edit the article */ public void setCoJournalistsForArticle(int articleID, List<String> coJournalists); public boolean deleteArticle(int articleID); public File getArticleLocation(); }