cloudcms-cli
Version:
Cloud CMS Command-Line client
185 lines (172 loc) • 6.6 kB
JavaScript
var helper = require("../../../helper");
var AbstractCommand = require("../../abstract");
class TransferImportCommand extends AbstractCommand
{
constructor()
{
super({
"group": "transfer",
"name": "import",
"description": "Import an archive into a referenced datastore",
"schema": {
"properties": [{
"name": "target",
"type": "string",
"description": "Enter the target datastore reference",
"helper": "The reference to the datastore you wish to conain the imported archive",
"required": true,
"args": ["target", "t"]
}, {
"name": "group",
"type": "string",
"description": "Enter the archive group ID:",
"helper": "The group ID of the archive that should be imported",
"required": true,
"args": ["group", "g"]
}, {
"name": "artifact",
"type": "string",
"description": "Enter the archive artifact ID:",
"helper": "The artifact ID of the archive that should be exported",
"required": true,
"args": ["artifact", "a"]
}, {
"name": "version",
"type": "string",
"description": "Enter the archive version ID:",
"helper": "The version of the archive that should be exported",
"required": true,
"args": ["version", "v"]
}, {
"name": "vault",
"type": "boolean",
"description": "Vault ID",
"helper": "The ID of the vault that will received the exported archive",
"required": false,
"default": "primary",
"args": ["vault", "vaultId"]
}, {
"name": "strategy",
"type": "string",
"description": "Enter the import strategy:",
"helper": "The strategy to use for import. Valid values are COPY_EVERYTHING, CLONE, COPY_TOP. Default is COPY_EVERYTHING",
"required": false,
"args": ["strategy", "s"]
}, {
"name": "includeACLs",
"type": "boolean",
"required": false,
"args": ["includeACLs", "includeAcls"]
}, {
"name": "includeTeams",
"type": "boolean",
"required": false,
"args": ["includeteams"]
}, {
"name": "includeTeamMembers",
"type": "boolean",
"required": false,
"args": ["includeTeamMembers"]
}, {
"name": "includeRoles",
"type": "boolean",
"required": false,
"args": ["includeRoles"]
}, {
"name": "includeActivities",
"type": "boolean",
"required": false,
"args": ["includeActivities"]
}, {
"name": "includeBinaries",
"type": "boolean",
"required": false,
"args": ["includeBinaries"]
}, {
"name": "includeAttachments",
"type": "boolean",
"required": false,
"args": ["includeAttachments"]
}, {
"name": "copyBinaries",
"type": "boolean",
"required": false,
"args": ["copyBinaries"]
}, {
"name": "copyAttachments",
"type": "boolean",
"required": false,
"args": ["copyAttachments"]
}, {
"name": "childrenOnly",
"type": "boolean",
"required": false,
"args": ["childrenOnly"]
}, {
"name": "dryRun",
"type": "boolean",
"required": false,
"args": ["dryRun"]
}, {
"name": "copyOnExisting",
"type": "boolean",
"required": false,
"args": ["copyOnExisting"]
}, {
"name": "requireAllIncludes",
"type": "boolean",
"required": false,
"args": ["requireAllIncludes"]
}, {
"name": "autoCleanup",
"type": "boolean",
"required": false,
"args": ["autoCleanup"]
}, {
"name": "autoPublish",
"type": "boolean",
"required": false,
"args": ["autoPublish"]
}, {
"name": "title",
"type": "string",
"required": false,
"args": ["title"]
}]
}
});
}
handle(options, callback)
{
var config = JSON.parse(JSON.stringify(options));
var target = config.target;
delete config.target;
var vaultId = config.vault;
delete config.vault;
var group = config.group;
delete config.group;
var artifact = config.artifact;
delete config.artifact;
var version = config.version;
delete config.version;
var title = config.title;
delete config.title;
if (title)
{
config.properties = {
"single_source_last": {
"title": title
}
};
}
if (config.strategy)
{
config.strategy = config.strategy.toUpperCase();
}
// call workhorse function
helper.importArchive(target, group, artifact, version, vaultId, config, function(err) {
callback(err);
});
}
}
module.exports = TransferImportCommand;