ServalDClient client = new ServerControl().getRestfulClient();
try {
RhizomeIncompleteManifest manifest = new RhizomeIncompleteManifest();
if (manifestPath != null && manifestPath.length() != 0)
manifest.parseTextFormat(new FileInputStream(manifestPath));
RhizomeInsertBundle bundle;
SubscriberId authorSid = author == null || author.length() == 0 ? null : new SubscriberId(author);
BundleSecret secret = secretHex == null || secretHex.length() == 0 ? null : new BundleSecret(secretHex);
if (payloadName == null || payloadName.length() == 0)
payloadName = new File(payloadPath).getName();
if (payloadPath == null || payloadPath.length() == 0)
bundle = client.rhizomeInsert(authorSid, manifest, secret);
else
bundle = client.rhizomeInsert(authorSid, manifest, secret, new FileInputStream(payloadPath), payloadName);
System.out.println(
"_status=" + bundle.status + "\n" +
(bundle.rowId == null ? "" : "_rowId=" + bundle.rowId + "\n") +
(bundle.insertTime == null ? "" : "_insertTime=" + bundle.insertTime + "\n") +
(bundle.author == null ? "" : "_author=" + bundle.author + "\n") +
(bundle.secret == null ? "" : "_secret=" + bundle.secret + "\n") +
manifestFields(bundle.manifest, "\n") + "\n"
);
if (manifestoutpath != null && manifestoutpath.length() != 0) {
FileOutputStream out = new FileOutputStream(manifestoutpath);
out.write(bundle.manifestText());
out.close();
}
}
catch (RhizomeManifestParseException e) {
System.out.println(e.toString());