Permalink
Browse files

Cleaned up some of the code post HOLD demonstration.

  • Loading branch information...
1 parent 3b6836b commit 84b7e24f5664808c328aeae8862cd6e9108cd43e behrens committed Nov 4, 2010
View
4 README
@@ -1,6 +1,6 @@
This is the R2AD Client Client community edition open souce repository.
-Version 0.1
-July 2010 after OGF-29
+Version 0.2
+Sept 2010 for the SDC 2010 conference
Visit http://cloud.r2ad.net for more informaiton.
The JavaFX and related code is intendend to be used within the NetBeans IDE.
@@ -18,11 +18,11 @@ import org.occi.model.OCCIStorageType;
import com.r2ad.cloud.cloudclient.parsers.storage.CDMIRootContainerParser;
import com.r2ad.cloud.cloudclient.parsers.storage.CDMIDeleteContainer;
import com.r2ad.cloud.cloudclient.parsers.storage.CDMICreateContainer;
-import com.r2ad.cloud.cloudclient.parsers.compute.OCCINodeParser;
import org.occi.model.OCCINetworkType;
import com.r2ad.cloud.cloudclient.parsers.compute.OCCICreateDisk;
import com.r2ad.cloud.cloudclient.parsers.storage.CDMICreateObject;
import java.io.File;
+import com.r2ad.cloud.cloudclient.parsers.compute.RackSpaceParser;
/**
* @author David K. Moolenaar, R2AD LLC
@@ -100,7 +100,7 @@ public class CloudDataManager {
if (computeConnection != null) {
//println("queryComputeConnection....");
OCCINodeParser.getComputeNode("");
- // Test for external real rackspace account:
+ // Uncomment below to test for external real rackspace account:
//RackSpaceParser.getAuthToken();
}
}
@@ -47,7 +47,7 @@ import org.occi.model.OCCIComputeType;
public function getAuthToken() : Void {
connection = controller.dataManager.getComputeConnection();
domainURI = new URI("{connection.connection}");
- connection.updateStatus("Getting OCCI resource...domainURI: {domainURI}");
+ connection.updateStatus("Getting Rackspace resource...domainURI: {domainURI}");
println("{myName}: getDetails from rackspace to: {connection}");
var authenticationHeader = HttpHeader.basicAuth(connection.user, connection.credentials);
@@ -65,7 +65,6 @@ import org.occi.model.OCCIComputeType;
name: "X-Auth-Key";
value:"{connection.credentials}"
//https://auth.api.rackspacecloud.com/v1.0
- //d5bce70010d9ae199ab51ff25b255f43
};
var request : HttpRequest = HttpRequest {
// TBD: Actually, need to get the path to the resource
@@ -114,8 +113,7 @@ import org.occi.model.OCCIComputeType;
onToRead: function(bytes: Long) {
println("bytes to read: {bytes}");
- connection.updateStatus("Reading {bytes} OCCI bytes");
-
+ connection.updateStatus("Reading {bytes} rackspace bytes");
}
// The onRead callback is called when some more data has been read into
@@ -134,7 +132,7 @@ import org.occi.model.OCCIComputeType;
} finally {
is.close();
println("{myName}: Finished Parsing");
- connection.updateStatus("Finisihed parsing OCCI Node");
+ connection.updateStatus("Finisihed parsing rackspace Node");
}
}
}
@@ -156,8 +154,6 @@ def parseEventCallback = function(event: Event) {
}
}
-// temporary variables needed during processing
-//var result: NodeModel;
function processStartEvent(event: Event) {
if (event.qname.name == "Result" and event.level == 1) {
@@ -42,10 +42,11 @@ import java.io.FileReader;
public var controller: Controller = bind controller.controller;
var myName = "CDMICreateObject";
var content: StringBuilder = new StringBuilder();
+ var contentLength = 0;
- // Information about all relevant cloud nodes
- //public var cloudNodes: NodeModel[];
-
+ /*
+ * Called to upload or create the object on the connected CDMI node.
+ */
public function createObject(sModel: OCCIStorageType) : Void {
var storedObject: StoredObject = sModel.getObject();
@@ -57,7 +58,6 @@ import java.io.FileReader;
println ("WARNING - Create Object called and flag is FALSE");
}
-
var resultsProcessor: function(is: InputStream) : Void;
var connection = controller.dataManager.getStorageConnection();
println("{myName} Connecting to: {connection}");
@@ -67,11 +67,19 @@ import java.io.FileReader;
var versionHeader: HttpHeader;
if (storedObject.isCDMIContentType()) {
+
+ // HoLD Lab content lines should be below:
+ // Insert here StringBuilder append lines as needed to
+ // comply with CDMI spec for an object PUT.
+ // i.e. content.append("\{\n");
+ // etc.
+
content.append("\{\n");
content.append("\t\"mimetype\" : \"text/plain\",\n");
content.append("\t\"metadata\" : \{\n");
content.append("\n\t\},\n");
content.append("\t\"value\" : \"");
+
// Read the file and inject as a CDMI text:
var text: StringBuilder = new StringBuilder();
//use buffering, reading one line at a time
@@ -80,23 +88,29 @@ import java.io.FileReader;
try {
var line: String = null; //not declared within while loop
while (( line = input.readLine()) != null){
+ println("{myName}: object content: {line}");
+ // HoLD Lab TODO: Also append each line from the file:
+
content.append("{line}");
}
}
finally{
input.close();
}
+ //
+ // HoLD Lab TODO: Do not foget the closing syntax:
+ //
+
content.append("\"\n");
content.append("\}\n");
var contentBytes : Byte[] = content.toString().getBytes();
- var contentLength = contentBytes.size();
+ contentLength = contentBytes.size();
var contentLengthHeader = HttpHeader {
name: HttpHeader.CONTENT_LENGTH,
value:"{contentLength}"
};
-
acceptHeader = HttpHeader {
name: HttpHeader.ACCEPT,
value:"application/vnd.org.snia.cdmi.dataobject+json"
@@ -199,7 +213,12 @@ import java.io.FileReader;
}
}
- request.start();
+ if (contentLength > 0) {
+ println("{myName}: Initiating object PUT request, len=: {contentLength}");
+ request.start();
+ } else {
+ println("{myName}: Object Request Aborted...zero content size!");
+ }
}
@@ -32,9 +32,9 @@ import javafx.scene.control.CheckBox;
import javafx.scene.paint.Color;
/**
- * Allows the user to modify the VM details such as its name,
- * core Count, Memory, notes, etc.
- * Also allows to delete the task.
+ * StorageEditorView
+ * Allows the user to modify the storage details such as its name,
+ * Also allows file objects to be uploaded to the container.
*/
public class StorageEditorView extends AppView {
@@ -225,7 +225,7 @@ public class StorageEditorView extends AppView {
storedObject.setCDMIContentType(CDMIObjectFlag);
storageType.addObject(storedObject);
filesLabelText="Files: {uploadFile.toString()}";
- uploadActionButton.text="Delete"
+ //uploadActionButton.text="Delete"
// Later on, process delete action, etc as a list of file objects.
}

0 comments on commit 84b7e24

Please sign in to comment.