Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Transfer Files to Other Network Location in Packages
Groovy Script - Transfer Files to Other Network Location in Packages
Updated yesterday

Description: Sample groovy script to create customized packages of files to transfer them at any external location

Context: Document

Remark: Accessible in 'Post' task mode only

Script:

def execute(){

/*Get revision details, if you want to get all the details use RevisionDetailsOption.ALL_DETAILS option. Include only those options in HashMap for the specific files you want to get details.*/

HashMap detailOptions = new HashMap();

detailOptions.put(RevisionDetailsOption.BASIC_DETAILS, true);

detailOptions.put(RevisionDetailsOption.CUSTOM_ATTRIBUTES, true);

detailOptions.put(RevisionDetailsOption.ATTACHMENT_DETAILS, true);

detailOptions.put(RevisionDetailsOption.DIRECT_ACCESS_LINK, true);

DocumentVO document = documentService.getDocumentDetails(detailOptions);

// create Json from DocumentVO based on given template

String docJson = documentService.toJSON(document, "");

// Use below method if you want to create XML file of metadata

// String docXml = documentService.toXML(document, "");

/* Create customized package and initiate transfer. if you want to include all the files in package, use RevisionDetailsOption.ALL_FILES option. Include only those options in HashMap for the specific files you want to include in the package. The value (second parameter) in packageOptions.put() is Folder path, use this option to create customized Folder structure or leave it as "" (blank) to use default folder structure.*/

HashMap packageOptions = new HashMap();

packageOptions.put(RevisionDetailsOption.REVISION_MAIN_FILE, "revisionfile");

packageOptions.put(RevisionDetailsOption.REVISION_METADATA_FILE, "metadata");

packageOptions.put(RevisionDetailsOption.EXTERNAL_ATTACHMENT_FILE, "attachment");

packageOptions.put(RevisionDetailsOption.ASSOCIATED_DISCUSSIONS_PDF, "associations\\discussion");

packageOptions.put(RevisionDetailsOption.ASSOCIATED_APPS_PDF, "associations\\apps");

packageOptions.put(RevisionDetailsOption.COMMENTS_PDF, "comments");

packageOptions.put(RevisionDetailsOption.COMMENTS_APPS_ASSOCIATIONS, "comments\\associatedapps");

packageOptions.put(RevisionDetailsOption.COMMENTS_FILES_ASSOCIATIONS, "comments\\associatedfiles");

packageOptions.put(RevisionDetailsOption.COMMENTS_ATTACHMENTS, "comments\\attachments");

documentService.createPackageAndTransfer(packageOptions, docJson, "Json");

}



Did this answer your question?