changeset 1328:a10d8e643220

Document Storage API as throwing StorageException Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-November/008736.html
author Omair Majid <omajid@redhat.com>
date Thu, 14 Nov 2013 13:16:30 -0500
parents 4bd366153706
children 73167580250d
files storage/core/src/main/java/com/redhat/thermostat/storage/core/Add.java storage/core/src/main/java/com/redhat/thermostat/storage/core/DataModifyingStatement.java storage/core/src/main/java/com/redhat/thermostat/storage/core/PreparedStatement.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Query.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Remove.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Replace.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Storage.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Update.java
diffstat 8 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Add.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Add.java	Thu Nov 14 13:16:30 2013 -0500
@@ -63,6 +63,8 @@
 
     /**
      * Applies this {@code Add} operation to storage.
+     *
+     * @throws StorageException if the operation fails
      */
     int apply();
 }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/DataModifyingStatement.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/DataModifyingStatement.java	Thu Nov 14 13:16:30 2013 -0500
@@ -23,6 +23,8 @@
     
     /**
      * Executes this statement.
+     *
+     * @throws StorageException if this statement fails to apply
      * 
      * @return a number greater than or equal to zero on success. A negative
      *         failure code otherwise.
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/PreparedStatement.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/PreparedStatement.java	Thu Nov 14 13:16:30 2013 -0500
@@ -30,6 +30,9 @@
      * 
      * @throws StatementExecutionException
      *             If the prepared statement wasn't valid for execution.
+     * @throws StorageException
+     *             If the underlying storage throws an exception while executing
+     *             this statement
      */
     int execute() throws StatementExecutionException;
 
@@ -40,6 +43,9 @@
      * 
      * @throws StatementExecutionException
      *             If the prepared statement wasn't valid for execution.
+     * @throws StorageException
+     *             If the underlying storage throws an exception while executing
+     *             this query
      */
     Cursor<T> executeQuery() throws StatementExecutionException;
     
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Query.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Query.java	Thu Nov 14 13:16:30 2013 -0500
@@ -65,6 +65,12 @@
 
     void limit(int n);
 
+    /**
+     * @throws StorageException
+     *             If the operation fails
+     *
+     * @return a {@link Cursor} that can be used to iterate over the results.
+     */
     Cursor<T> execute();
     
     Expression getWhereExpression();
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Remove.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Remove.java	Thu Nov 14 13:16:30 2013 -0500
@@ -60,6 +60,8 @@
     
     /**
      * Applies this remove operation.
+     *
+     * @throws StorageException if this operation fails
      */
     int apply();
 
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Replace.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Replace.java	Thu Nov 14 13:16:30 2013 -0500
@@ -77,6 +77,8 @@
 
     /**
      * Applies this {@code Replace} operation to the storage.
+     *
+     * @throws StorageException If the operation fails
      */
     int apply();
 
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Storage.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Storage.java	Thu Nov 14 13:16:30 2013 -0500
@@ -49,6 +49,14 @@
 @Service
 public interface Storage {
 
+    /**
+     * Register the category into the Storage. A Category must be registered
+     * into storage (normally handled by the Category's constructor) before it
+     * can be used.
+     *
+     * @throws StorageException
+     *             If the category can not be registered for some reason
+     */
     void registerCategory(Category<?> category);
     
     /**
@@ -77,13 +85,36 @@
 
     /**
      * Drop all data related to the specified agent.
+     *
+     * @param agentId
+     *            The id of the agent
+     * @throws StorageException
+     *            If the purge operation fails
      */
     void purge(String agentId);
 
+    /**
+     * Save the contents of the input stream as the given name.
+     *
+     * @throws StorageException
+     *            If the save operation fails
+     */
     void saveFile(String filename, InputStream data);
 
+    /**
+     * Load the file with the given name and return the data as an InputStream.
+     *
+     * @throws StorageException
+     *            If the load operation fails
+     */
     InputStream loadFile(String filename);
 
+    /**
+     * Shutdown the storage
+     *
+     * @throws StorageException
+     *            If the shutdown operation fails
+     */
     void shutdown();
 
 }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Update.java	Thu Nov 14 19:20:01 2013 +0100
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Update.java	Thu Nov 14 13:16:30 2013 -0500
@@ -73,6 +73,8 @@
 
     /**
      * Applies this update operation.
+     *
+     * @throws StorageException if this operation fails
      */
     int apply();
 }