}
}
- /**
- * Notifies all listeners that a request was added to a node.
- *
- * @param request
- * The request that was added
- */
- private void fireRequestAdded(Request request) {
- for (CoreListener coreListener: coreListeners) {
- coreListener.requestAdded(request);
- }
- }
-
- /**
- * Notifies all listeners that a request progressed.
- *
- * @param request
- * The request
- */
- private void fireRequestProgressed(Request request) {
- for (CoreListener coreListener: coreListeners) {
- coreListener.requestProgressed(request);
- }
- }
-
- /**
- * Notifies all listeners that a request was removed.
- *
- * @param request
- * The request that was removed
- */
- private void fireRequestRemoved(Request request) {
- for (CoreListener coreListener: coreListeners) {
- coreListener.requestRemoved(request);
- }
- }
-
//
// ACCESSORS
//
* {@inheritDoc}
*/
public void requestAdded(Request request) {
- fireRequestAdded(request);
+ /* TODO - find project and process request */
}
/**
* @see net.pterodactylus.jsite.core.RequestListener#requestProgressed(Request)
*/
public void requestProgressed(Request request) {
- fireRequestProgressed(request);
+ /* TODO - find project and process request */
}
/**
* @see net.pterodactylus.jsite.core.RequestListener#requestRemoved(net.pterodactylus.jsite.core.Request)
*/
public void requestRemoved(Request request) {
- fireRequestRemoved(request);
+ /* TODO - find project and process request */
+ }
+
+ /**
+ * @see net.pterodactylus.jsite.core.RequestListener#requestGeneratedURI(net.pterodactylus.jsite.core.Request, java.lang.String)
+ */
+ public void requestGeneratedURI(Request request, String uri) {
+ /* TODO - find project and process request */
}
+
+ /**
+ * @see net.pterodactylus.jsite.core.RequestListener#requestFinished(net.pterodactylus.jsite.core.Request)
+ */
+ public void requestFinished(Request request) {
+ /* TODO - find project and process request */
+ }
}
package net.pterodactylus.jsite.core;
+import net.pterodactylus.jsite.project.Project;
+
/**
* Interface definition for user interfaces.
*
public void nodeDisconnected(Node node, Throwable throwable);
//
- // request stuff
+ // project insertion stuff
//
/**
- * Notifies a listener that a request was added to a node.
+ * Notifies a listener that a project insert started.
+ *
+ * @param project
+ * The project that is now inserting
+ */
+ public void projectInsertStarted(Project project);
+
+ /**
+ * Notifies a listener that a project insert made progress.
*
- * @param request
- * The request that was added
+ * @param project
+ * The project that made progress
+ * @param totalBlocks
+ * The number of total blocks
+ * @param requiredBlocks
+ * The number of required blocks
+ * @param successfulBlocks
+ * The number of successfully inserted blocks
+ * @param failedBlocks
+ * The number of blocks that could not be inserted
+ * @param fatallyFailedBlocks
+ * The number of blocks that can not be inserted even with
+ * retries
+ * @param finalizedTotal
+ * <code>true</code> if the number of total blocks is already
+ * finalized, <code>false</code> otherwise
*/
- public void requestAdded(Request request);
+ public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
/**
- * Notifies a listener that a request made some progress.
+ * Notifies a listener that a project insert has generated a URI.
*
- * @param request
- * The request that made the progress
+ * @param project
+ * The project that generated a URI
+ * @param uri
+ * The URI that was generated
*/
- public void requestProgressed(Request request);
+ public void projectInsertGeneratedURI(Project project, String uri);
/**
- * Notifies a listener that a request was removed.
+ * Notifies a listener that a project insert has finished.
*
- * @param request
- * The request that was removed
+ * @param project
+ * The project that has finished
+ * @param success
+ * <code>true</code> if the project was inserted successfully,
+ * <code>false</code> otherwise
*/
- public void requestRemoved(Request request);
+ public void projectInsertFinished(Project project, boolean success);
}
/** Name of the “fetchable” property. */
public static final String PROPERTY_FETCHABLE = "fetchable";
+ /** Name of the “URI” property. */
+ public static final String PROPERTY_URI = "uri";
+
/** Name of the “total blocks” property. */
public static final String PROPERTY_TOTAL_BLOCKS = "totalBlocks";
/** Whether the data is already fetchable (in case of put requests). */
private boolean fetchable;
+ /** The generated URI. */
+ private String uri;
+
/** The total number of blocks. */
private int totalBlocks;
}
/**
+ * Returns the URI generated by this request.
+ *
+ * @return The generated URI
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the URI generated by this request.
+ *
+ * @param uri
+ * The generated URI
+ */
+ void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ /**
* Returns the total number of blocks of a request. Until
* {@link #isTotalFinalized()} returns <code>true</code> this value may
* change!
*/
public void requestRemoved(Request request);
+ /**
+ * Notifies a listener that a Put request has generated a URI.
+ *
+ * @param request
+ * The request that generated a URI
+ * @param uri
+ * The generated URI
+ */
+ public void requestGeneratedURI(Request request, String uri);
+
+ /**
+ * Notifies a listener that a request has completed.
+ *
+ * @param request
+ * The finished request
+ */
+ public void requestFinished(Request request);
+
}
}
}
+ /**
+ * Notifies all listeners that a request has finished.
+ *
+ * @see RequestListener#requestFinished(Request)
+ * @param request
+ * The request that has finished
+ */
+ private void fireRequestFinished(Request request) {
+ for (RequestListener requestListener: requestListeners) {
+ requestListener.requestFinished(request);
+ }
+ }
+
+ /**
+ * Notifies all listeners that a request has generated a URI.
+ *
+ * @see RequestListener#requestGeneratedURI(Request, String)
+ * @param request
+ * The request that has generated a URI
+ * @param uri
+ * The generated URI
+ */
+ private void fireRequestGeneratedURI(Request request, String uri) {
+ for (RequestListener requestListener: requestListeners) {
+ requestListener.requestGeneratedURI(request, uri);
+ }
+ }
+
//
// ACCESSORS
//
identifierRequests.put(identifier, request);
fireRequestAdded(request);
}
- request.setTotalBlocks(highLevelProgress.getTotalBlocks());
- request.setRequiredBlocks(highLevelProgress.getRequiredBlocks());
- request.setSuccessfulBlocks(highLevelProgress.getSuccessfulBlocks());
- request.setFailedBlocks(highLevelProgress.getFailedBlocks());
- request.setFatallyFailedBlocks(highLevelProgress.getFatallyFailedBlocks());
- request.setTotalFinalized(highLevelProgress.isTotalFinalized());
- fireRequestProgressed(request);
+ if (highLevelProgress.isFinished()) {
+ request.setFinished(true);
+ request.setSuccessful(!highLevelProgress.isFailed());
+ fireRequestFinished(request);
+ } else if (highLevelProgress.isFetchable()) {
+ /* TODO - ignore? */
+ } else if (highLevelProgress.getURI() != null) {
+ request.setURI(highLevelProgress.getURI());
+ fireRequestGeneratedURI(request, highLevelProgress.getURI());
+ } else {
+ request.setTotalBlocks(highLevelProgress.getTotalBlocks());
+ request.setRequiredBlocks(highLevelProgress.getRequiredBlocks());
+ request.setSuccessfulBlocks(highLevelProgress.getSuccessfulBlocks());
+ request.setFailedBlocks(highLevelProgress.getFailedBlocks());
+ request.setFatallyFailedBlocks(highLevelProgress.getFatallyFailedBlocks());
+ request.setTotalFinalized(highLevelProgress.isTotalFinalized());
+ fireRequestProgressed(request);
+ }
}
}
import net.pterodactylus.jsite.core.CoreListener;
import net.pterodactylus.jsite.core.JSiteException;
import net.pterodactylus.jsite.core.Node;
-import net.pterodactylus.jsite.core.Request;
import net.pterodactylus.jsite.i18n.I18n;
import net.pterodactylus.jsite.i18n.gui.I18nAction;
import net.pterodactylus.jsite.project.Project;
}
/**
- * {@inheritDoc}
+ * @see net.pterodactylus.jsite.core.CoreListener#projectInsertStarted(net.pterodactylus.jsite.project.Project)
*/
- public void requestAdded(Request request) {
- logger.log(Level.INFO, "request added to node: " + request + ", " + request.getNode());
- /* TODO - implement */
+ public void projectInsertStarted(Project project) {
+ /* TODO - show in interface */
}
/**
- * {@inheritDoc}
+ * @see net.pterodactylus.jsite.core.CoreListener#projectInsertProgressed(net.pterodactylus.jsite.project.Project,
+ * int, int, int, int, int, boolean)
+ */
+ public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal) {
+ /* TODO - show in interface */
+ }
+
+ /**
+ * @see net.pterodactylus.jsite.core.CoreListener#projectInsertGeneratedURI(net.pterodactylus.jsite.project.Project,
+ * java.lang.String)
*/
- public void requestProgressed(Request request) {
- /* TODO - implement */
+ public void projectInsertGeneratedURI(Project project, String uri) {
+ /* TODO - show in interface */
}
/**
- * @see net.pterodactylus.jsite.core.CoreListener#requestRemoved(net.pterodactylus.jsite.core.Request)
+ * @see net.pterodactylus.jsite.core.CoreListener#projectInsertFinished(net.pterodactylus.jsite.project.Project,
+ * boolean)
*/
- public void requestRemoved(Request request) {
- /* TODO - implement */
+ public void projectInsertFinished(Project project, boolean success) {
+ /* TODO - show in interface */
}
//