# HG changeset patch # User František Kučera # Date 1318111225 -7200 # Node ID 72950b29569ed76db523d4f2f36e58f001cb602e # Parent d883d4ab7b9dc2bb9f6cd7f70f1e763b963c9a7a Drupal: bez dědičnosti, implementujeme rovnou rozhraní (nelze dědit). diff -r d883d4ab7b9d -r 72950b29569e src/org/sonews/storage/impl/DrupalDatabase.java --- a/src/org/sonews/storage/impl/DrupalDatabase.java Sat Oct 08 23:32:18 2011 +0200 +++ b/src/org/sonews/storage/impl/DrupalDatabase.java Sun Oct 09 00:00:25 2011 +0200 @@ -17,9 +17,176 @@ */ package org.sonews.storage.impl; +import java.sql.SQLException; +import java.util.List; +import org.sonews.feed.Subscription; +import org.sonews.storage.Article; +import org.sonews.storage.ArticleHead; +import org.sonews.storage.Group; +import org.sonews.storage.Storage; +import org.sonews.storage.StorageBackendException; +import org.sonews.util.Pair; + /** * * @author František Kučera (frantovo.cz) */ -public class DrupalDatabase extends JDBCDatabase { +public class DrupalDatabase implements Storage { + + /** + * Rises the database: reconnect and recreate all prepared statements. + * @throws java.lang.SQLException + */ + protected void arise() throws SQLException { + } + + @Override + public void addArticle(Article art) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public void addEvent(long timestamp, int type, long groupID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public void addGroup(String groupname, int flags) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int countArticles() throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int countGroups() throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public void delete(String messageID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public Article getArticle(String messageID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public Article getArticle(long articleIndex, long groupID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List> getArticleHeads(Group group, long first, long last) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List> getArticleHeaders(Group group, long start, long end, String header, String pattern) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public long getArticleIndex(Article art, Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List getArticleNumbers(long groupID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public String getConfigValue(String key) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int getEventsCount(int eventType, long startTimestamp, long endTimestamp, Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public double getEventsPerHour(int key, long gid) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int getFirstArticleNumber(Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public Group getGroup(String name) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List getGroups() throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List getGroupsForList(String listAddress) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int getLastArticleNumber(Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List getListsForGroup(String groupname) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public String getOldestArticle() throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public int getPostingsCount(String groupname) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public List getSubscriptions(int type) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public boolean isArticleExisting(String messageID) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public boolean isGroupExisting(String groupname) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public void purgeGroup(Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public void setConfigValue(String key, String value) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public boolean update(Article article) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } + + @Override + public boolean update(Group group) throws StorageBackendException { + throw new StorageBackendException("Not supported yet."); + } } diff -r d883d4ab7b9d -r 72950b29569e src/org/sonews/storage/impl/DrupalDatabaseProvider.java --- a/src/org/sonews/storage/impl/DrupalDatabaseProvider.java Sat Oct 08 23:32:18 2011 +0200 +++ b/src/org/sonews/storage/impl/DrupalDatabaseProvider.java Sun Oct 09 00:00:25 2011 +0200 @@ -18,14 +18,24 @@ package org.sonews.storage.impl; import java.sql.SQLException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.sonews.storage.Storage; import org.sonews.storage.StorageBackendException; +import org.sonews.storage.StorageProvider; /** * * @author František Kučera (frantovo.cz) */ -public class DrupalDatabaseProvider extends JDBCDatabaseProvider { +public class DrupalDatabaseProvider implements StorageProvider { + + protected static final Map instances = new ConcurrentHashMap(); + + @Override + public boolean isSupported(String uri) { + return uri.startsWith("jdbc:mysql") || uri.startsWith("jdbc:postgresql"); + } @Override public Storage storage(Thread thread)