Drupal: bez dědičnosti, implementujeme rovnou rozhraní (nelze dědit).
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 09 Oct 2011 00:00:25 +0200
changeset 6472950b29569e
parent 63 d883d4ab7b9d
child 65 b58cab5be0f4
Drupal: bez dědičnosti, implementujeme rovnou rozhraní (nelze dědit).
src/org/sonews/storage/impl/DrupalDatabase.java
src/org/sonews/storage/impl/DrupalDatabaseProvider.java
     1.1 --- a/src/org/sonews/storage/impl/DrupalDatabase.java	Sat Oct 08 23:32:18 2011 +0200
     1.2 +++ b/src/org/sonews/storage/impl/DrupalDatabase.java	Sun Oct 09 00:00:25 2011 +0200
     1.3 @@ -17,9 +17,176 @@
     1.4   */
     1.5  package org.sonews.storage.impl;
     1.6  
     1.7 +import java.sql.SQLException;
     1.8 +import java.util.List;
     1.9 +import org.sonews.feed.Subscription;
    1.10 +import org.sonews.storage.Article;
    1.11 +import org.sonews.storage.ArticleHead;
    1.12 +import org.sonews.storage.Group;
    1.13 +import org.sonews.storage.Storage;
    1.14 +import org.sonews.storage.StorageBackendException;
    1.15 +import org.sonews.util.Pair;
    1.16 +
    1.17  /**
    1.18   *
    1.19   * @author František Kučera (frantovo.cz)
    1.20   */
    1.21 -public class DrupalDatabase extends JDBCDatabase {
    1.22 +public class DrupalDatabase implements Storage {
    1.23 +
    1.24 +	/**
    1.25 +	 * Rises the database: reconnect and recreate all prepared statements.
    1.26 +	 * @throws java.lang.SQLException
    1.27 +	 */
    1.28 +	protected void arise() throws SQLException {
    1.29 +	}
    1.30 +
    1.31 +	@Override
    1.32 +	public void addArticle(Article art) throws StorageBackendException {
    1.33 +		throw new StorageBackendException("Not supported yet.");
    1.34 +	}
    1.35 +
    1.36 +	@Override
    1.37 +	public void addEvent(long timestamp, int type, long groupID) throws StorageBackendException {
    1.38 +		throw new StorageBackendException("Not supported yet.");
    1.39 +	}
    1.40 +
    1.41 +	@Override
    1.42 +	public void addGroup(String groupname, int flags) throws StorageBackendException {
    1.43 +		throw new StorageBackendException("Not supported yet.");
    1.44 +	}
    1.45 +
    1.46 +	@Override
    1.47 +	public int countArticles() throws StorageBackendException {
    1.48 +		throw new StorageBackendException("Not supported yet.");
    1.49 +	}
    1.50 +
    1.51 +	@Override
    1.52 +	public int countGroups() throws StorageBackendException {
    1.53 +		throw new StorageBackendException("Not supported yet.");
    1.54 +	}
    1.55 +
    1.56 +	@Override
    1.57 +	public void delete(String messageID) throws StorageBackendException {
    1.58 +		throw new StorageBackendException("Not supported yet.");
    1.59 +	}
    1.60 +
    1.61 +	@Override
    1.62 +	public Article getArticle(String messageID) throws StorageBackendException {
    1.63 +		throw new StorageBackendException("Not supported yet.");
    1.64 +	}
    1.65 +
    1.66 +	@Override
    1.67 +	public Article getArticle(long articleIndex, long groupID) throws StorageBackendException {
    1.68 +		throw new StorageBackendException("Not supported yet.");
    1.69 +	}
    1.70 +
    1.71 +	@Override
    1.72 +	public List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last) throws StorageBackendException {
    1.73 +		throw new StorageBackendException("Not supported yet.");
    1.74 +	}
    1.75 +
    1.76 +	@Override
    1.77 +	public List<Pair<Long, String>> getArticleHeaders(Group group, long start, long end, String header, String pattern) throws StorageBackendException {
    1.78 +		throw new StorageBackendException("Not supported yet.");
    1.79 +	}
    1.80 +
    1.81 +	@Override
    1.82 +	public long getArticleIndex(Article art, Group group) throws StorageBackendException {
    1.83 +		throw new StorageBackendException("Not supported yet.");
    1.84 +	}
    1.85 +
    1.86 +	@Override
    1.87 +	public List<Long> getArticleNumbers(long groupID) throws StorageBackendException {
    1.88 +		throw new StorageBackendException("Not supported yet.");
    1.89 +	}
    1.90 +
    1.91 +	@Override
    1.92 +	public String getConfigValue(String key) throws StorageBackendException {
    1.93 +		throw new StorageBackendException("Not supported yet.");
    1.94 +	}
    1.95 +
    1.96 +	@Override
    1.97 +	public int getEventsCount(int eventType, long startTimestamp, long endTimestamp, Group group) throws StorageBackendException {
    1.98 +		throw new StorageBackendException("Not supported yet.");
    1.99 +	}
   1.100 +
   1.101 +	@Override
   1.102 +	public double getEventsPerHour(int key, long gid) throws StorageBackendException {
   1.103 +		throw new StorageBackendException("Not supported yet.");
   1.104 +	}
   1.105 +
   1.106 +	@Override
   1.107 +	public int getFirstArticleNumber(Group group) throws StorageBackendException {
   1.108 +		throw new StorageBackendException("Not supported yet.");
   1.109 +	}
   1.110 +
   1.111 +	@Override
   1.112 +	public Group getGroup(String name) throws StorageBackendException {
   1.113 +		throw new StorageBackendException("Not supported yet.");
   1.114 +	}
   1.115 +
   1.116 +	@Override
   1.117 +	public List<Group> getGroups() throws StorageBackendException {
   1.118 +		throw new StorageBackendException("Not supported yet.");
   1.119 +	}
   1.120 +
   1.121 +	@Override
   1.122 +	public List<String> getGroupsForList(String listAddress) throws StorageBackendException {
   1.123 +		throw new StorageBackendException("Not supported yet.");
   1.124 +	}
   1.125 +
   1.126 +	@Override
   1.127 +	public int getLastArticleNumber(Group group) throws StorageBackendException {
   1.128 +		throw new StorageBackendException("Not supported yet.");
   1.129 +	}
   1.130 +
   1.131 +	@Override
   1.132 +	public List<String> getListsForGroup(String groupname) throws StorageBackendException {
   1.133 +		throw new StorageBackendException("Not supported yet.");
   1.134 +	}
   1.135 +
   1.136 +	@Override
   1.137 +	public String getOldestArticle() throws StorageBackendException {
   1.138 +		throw new StorageBackendException("Not supported yet.");
   1.139 +	}
   1.140 +
   1.141 +	@Override
   1.142 +	public int getPostingsCount(String groupname) throws StorageBackendException {
   1.143 +		throw new StorageBackendException("Not supported yet.");
   1.144 +	}
   1.145 +
   1.146 +	@Override
   1.147 +	public List<Subscription> getSubscriptions(int type) throws StorageBackendException {
   1.148 +		throw new StorageBackendException("Not supported yet.");
   1.149 +	}
   1.150 +
   1.151 +	@Override
   1.152 +	public boolean isArticleExisting(String messageID) throws StorageBackendException {
   1.153 +		throw new StorageBackendException("Not supported yet.");
   1.154 +	}
   1.155 +
   1.156 +	@Override
   1.157 +	public boolean isGroupExisting(String groupname) throws StorageBackendException {
   1.158 +		throw new StorageBackendException("Not supported yet.");
   1.159 +	}
   1.160 +
   1.161 +	@Override
   1.162 +	public void purgeGroup(Group group) throws StorageBackendException {
   1.163 +		throw new StorageBackendException("Not supported yet.");
   1.164 +	}
   1.165 +
   1.166 +	@Override
   1.167 +	public void setConfigValue(String key, String value) throws StorageBackendException {
   1.168 +		throw new StorageBackendException("Not supported yet.");
   1.169 +	}
   1.170 +
   1.171 +	@Override
   1.172 +	public boolean update(Article article) throws StorageBackendException {
   1.173 +		throw new StorageBackendException("Not supported yet.");
   1.174 +	}
   1.175 +
   1.176 +	@Override
   1.177 +	public boolean update(Group group) throws StorageBackendException {
   1.178 +		throw new StorageBackendException("Not supported yet.");
   1.179 +	}
   1.180  }
     2.1 --- a/src/org/sonews/storage/impl/DrupalDatabaseProvider.java	Sat Oct 08 23:32:18 2011 +0200
     2.2 +++ b/src/org/sonews/storage/impl/DrupalDatabaseProvider.java	Sun Oct 09 00:00:25 2011 +0200
     2.3 @@ -18,14 +18,24 @@
     2.4  package org.sonews.storage.impl;
     2.5  
     2.6  import java.sql.SQLException;
     2.7 +import java.util.Map;
     2.8 +import java.util.concurrent.ConcurrentHashMap;
     2.9  import org.sonews.storage.Storage;
    2.10  import org.sonews.storage.StorageBackendException;
    2.11 +import org.sonews.storage.StorageProvider;
    2.12  
    2.13  /**
    2.14   *
    2.15   * @author František Kučera (frantovo.cz)
    2.16   */
    2.17 -public class DrupalDatabaseProvider extends JDBCDatabaseProvider {
    2.18 +public class DrupalDatabaseProvider implements StorageProvider {
    2.19 +
    2.20 +	protected static final Map<Thread, DrupalDatabase> instances = new ConcurrentHashMap<Thread, DrupalDatabase>();
    2.21 +
    2.22 +	@Override
    2.23 +	public boolean isSupported(String uri) {
    2.24 +		return uri.startsWith("jdbc:mysql") || uri.startsWith("jdbc:postgresql");
    2.25 +	}
    2.26  
    2.27  	@Override
    2.28  	public Storage storage(Thread thread)