<dependency>
<groupId>org.freenetproject</groupId>
<artifactId>fred</artifactId>
- <version>0.7.5.1405</version>
+ <version>0.7.5.1467-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
import net.pterodactylus.sone.data.TemporaryImage;
import net.pterodactylus.util.logging.Logging;
-import com.db4o.ObjectContainer;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import freenet.client.ClientMetadata;
import freenet.client.FetchException;
+import freenet.client.FetchException.FetchExceptionMode;
import freenet.client.FetchResult;
import freenet.client.HighLevelSimpleClient;
import freenet.client.HighLevelSimpleClientImpl;
import freenet.keys.InsertableClientSSK;
import freenet.keys.USK;
import freenet.node.Node;
+import freenet.node.RequestClient;
import freenet.node.RequestStarter;
import freenet.support.api.Bucket;
+import freenet.support.api.RandomAccessBucket;
import freenet.support.io.ArrayBucket;
+import freenet.support.io.ResumeFailedException;
/**
* Contains all necessary functionality for interacting with the Freenet node.
fetchResult = client.fetch(currentUri);
return new Fetched(currentUri, fetchResult);
} catch (FetchException fe1) {
- if (fe1.getMode() == FetchException.PERMANENT_REDIRECT) {
+ if (fe1.getMode() == FetchExceptionMode.PERMANENT_REDIRECT) {
currentUri = fe1.newURI;
continue;
}
InsertableClientSSK key = InsertableClientSSK.createRandom(node.random, "");
FreenetURI targetUri = key.getInsertURI().setDocName(filenameHint);
InsertContext insertContext = client.getInsertContext(true);
- Bucket bucket = new ArrayBucket(temporaryImage.getImageData());
+ RandomAccessBucket bucket = new ArrayBucket(temporaryImage.getImageData());
ClientMetadata metadata = new ClientMetadata(temporaryImage.getMimeType());
InsertBlock insertBlock = new InsertBlock(bucket, metadata, targetUri);
try {
- ClientPutter clientPutter = client.insert(insertBlock, false, null, false, insertContext, insertToken, RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+ ClientPutter clientPutter = client.insert(insertBlock, null, false, insertContext, insertToken, RequestStarter.INTERACTIVE_PRIORITY_CLASS);
insertToken.setClientPutter(clientPutter);
} catch (InsertException ie1) {
throw new SoneInsertException("Could not start image insert.", ie1);
@Override
@SuppressWarnings("synthetic-access")
- public void onFoundEdition(long edition, USK key, ObjectContainer objectContainer, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
+ public void onFoundEdition(long edition, USK key, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
logger.log(Level.FINE, String.format("Found USK update for Sone “%s” at %s, new known good: %s, new slot too: %s.", sone, key, newKnownGood, newSlotToo));
if (edition > sone.getLatestEdition()) {
sone.setLatestEdition(edition);
USKCallback uskCallback = new USKCallback() {
@Override
- public void onFoundEdition(long edition, USK key, ObjectContainer objectContainer, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
+ public void onFoundEdition(long edition, USK key, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
callback.editionFound(key.getURI(), edition, newKnownGood, newSlotToo);
}
*/
@SuppressWarnings("synthetic-access")
public void cancel() {
- clientPutter.cancel(null, node.clientCore.clientContext);
+ clientPutter.cancel(node.clientCore.clientContext);
eventBus.post(new ImageInsertAbortedEvent(image));
}
// INTERFACE ClientPutCallback
//
- /**
- * {@inheritDoc}
- */
@Override
- public void onMajorProgress(ObjectContainer objectContainer) {
- /* ignore, we don’t care. */
+ public RequestClient getRequestClient() {
+ return clientPutter.getClient();
+ }
+
+ @Override
+ public void onResume(ClientContext context) throws ResumeFailedException {
+ /* ignore. */
}
/**
*/
@Override
@SuppressWarnings("synthetic-access")
- public void onFailure(InsertException insertException, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
+ public void onFailure(InsertException insertException, BaseClientPutter clientPutter) {
if ((insertException != null) && ("Cancelled by user".equals(insertException.getMessage()))) {
eventBus.post(new ImageInsertAbortedEvent(image));
} else {
* {@inheritDoc}
*/
@Override
- public void onFetchable(BaseClientPutter clientPutter, ObjectContainer objectContainer) {
+ public void onFetchable(BaseClientPutter clientPutter) {
/* ignore, we don’t care. */
}
* {@inheritDoc}
*/
@Override
- public void onGeneratedMetadata(Bucket metadata, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
+ public void onGeneratedMetadata(Bucket metadata, BaseClientPutter clientPutter) {
/* ignore, we don’t care. */
}
* {@inheritDoc}
*/
@Override
- public void onGeneratedURI(FreenetURI generatedUri, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
+ public void onGeneratedURI(FreenetURI generatedUri, BaseClientPutter clientPutter) {
resultingUri = generatedUri;
}
*/
@Override
@SuppressWarnings("synthetic-access")
- public void onSuccess(BaseClientPutter clientPutter, ObjectContainer objectContainer) {
+ public void onSuccess(BaseClientPutter clientPutter) {
eventBus.post(new ImageInsertFinishedEvent(image, resultingUri));
}
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone.SoneStatus;
-import net.pterodactylus.sone.freenet.StringBucket;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.TemplateParser;
import net.pterodactylus.util.template.XmlFilter;
+import com.google.common.base.Charsets;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Ordering;
import com.google.common.eventbus.EventBus;
-import freenet.client.async.ManifestElement;
import freenet.keys.FreenetURI;
+import freenet.support.api.ManifestElement;
+import freenet.support.api.RandomAccessBucket;
+import freenet.support.io.ArrayBucket;
/**
* A Sone inserter is responsible for inserting a Sone if it has changed.
templateContext.set("currentEdition", core.getUpdateChecker().getLatestEdition());
templateContext.set("version", SonePlugin.VERSION);
StringWriter writer = new StringWriter();
- StringBucket bucket = null;
+ RandomAccessBucket bucket = null;
try {
template.render(templateContext, writer);
- bucket = new StringBucket(writer.toString(), utf8Charset);
+ bucket = new ArrayBucket(writer.toString().getBytes(Charsets.UTF_8));
return new ManifestElement(name, bucket, contentType, bucket.size());
} catch (TemplateException te1) {
logger.log(Level.SEVERE, String.format("Could not render template “%s”!", templateName), te1);
import net.pterodactylus.util.config.ConfigurationException;
import net.pterodactylus.util.config.ExtendedConfigurationBackend;
import net.pterodactylus.util.logging.Logging;
-import freenet.client.async.DatabaseDisabledException;
+import freenet.client.async.PersistenceDisabledException;
import freenet.pluginmanager.PluginRespirator;
import freenet.pluginmanager.PluginStore;
*
* @param pluginRespirator
* The plugin respirator
- * @throws DatabaseDisabledException
+ * @throws PersistenceDisabledException
* if the plugin store is not available
*/
- public PluginStoreConfigurationBackend(PluginRespirator pluginRespirator) throws DatabaseDisabledException {
+ public PluginStoreConfigurationBackend(PluginRespirator pluginRespirator) throws PersistenceDisabledException {
this.pluginRespirator = pluginRespirator;
this.pluginStore = pluginRespirator.getStore();
- if (this.pluginStore == null) {
- throw new DatabaseDisabledException();
- }
}
/**
public void save() throws ConfigurationException {
try {
pluginRespirator.putStore(pluginStore);
- } catch (DatabaseDisabledException dde1) {
- throw new ConfigurationException("Could not store plugin store, database is disabled.", dde1);
+ } catch (PersistenceDisabledException pde1) {
+ throw new ConfigurationException("Could not store plugin store, persistence is disabled.", pde1);
}
}
+++ /dev/null
-/*
- * Sone - StringBucket.java - Copyright © 2010–2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-
-import com.db4o.ObjectContainer;
-
-import freenet.support.api.Bucket;
-
-/**
- * {@link Bucket} implementation wrapped around a {@link String}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class StringBucket implements Bucket {
-
- /** The string to deliver. */
- private final String string;
-
- /** The encoding for the data. */
- private final Charset encoding;
-
- /**
- * Creates a new string bucket using the default encoding.
- *
- * @param string
- * The string to wrap
- */
- public StringBucket(String string) {
- this(string, Charset.defaultCharset());
- }
-
- /**
- * Creates a new string bucket, using the given encoding to create a byte
- * array from the string.
- *
- * @param string
- * The string to wrap
- * @param encoding
- * The encoding of the data
- */
- public StringBucket(String string, Charset encoding) {
- this.string = string;
- this.encoding = encoding;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Bucket createShadow() {
- return new StringBucket(string);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void free() {
- /* ignore. */
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStream getInputStream() {
- return new ByteArrayInputStream(string.getBytes(encoding));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return getClass().getName() + "@" + hashCode();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public OutputStream getOutputStream() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isReadOnly() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeFrom(ObjectContainer objectContainer) {
- /* ignore. */
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setReadOnly() {
- /* ignore, it is already read-only. */
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long size() {
- return string.getBytes(encoding).length;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void storeTo(ObjectContainer objectContainer) {
- /* ignore. */
- }
-
-}
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
-import freenet.client.async.DatabaseDisabledException;
+import freenet.client.async.PersistenceDisabledException;
import freenet.l10n.BaseL10n.LANGUAGE;
import freenet.l10n.PluginL10n;
import freenet.node.Node;
try {
oldConfiguration = new Configuration(new PluginStoreConfigurationBackend(pluginRespirator));
logger.log(Level.INFO, "Plugin store loaded.");
- } catch (DatabaseDisabledException dde1) {
+ } catch (PersistenceDisabledException pde1) {
logger.log(Level.SEVERE, "Could not load any configuration, using empty configuration!");
oldConfiguration = new Configuration(new MapConfigurationBackend());
}