import static com.axeda.sdk.v2.dsl.Bridges.* import com.axeda.sdk.v2.dsl.Bridges import com.axeda.services.v2.* import com.axeda.drm.sdk.scripto.Request import com.axeda.drm.sdk.scm.DownloadInstruction import com.axeda.drm.sdk.commons.compression.CompressionType import com.axeda.sdk.v2.bridge.SoftwarePackageBridge try { String packageName = Request.parameters.packageName assert packageName String packageVersion = Request.parameters.packageVersion assert packageVersion String res = "" def command def cmdProc File file String fileName String destinationDirectory = "c:\\Temp" DownloadInstruction instruction boolean isFileNotAdded = true SoftwarePackageBridge softwarePackageBridge = Bridges.getSoftwarePackageBridge() //Find the software package to update SoftwarePackage softwarePackageToUpdate = softwarePackageBridge.find(packageToFind) assert (softwarePackageToUpdate != null) command = ["sh", "-c", "ls -1 /var/tmp/delivery"] cmdProc = command.execute() cmdProc.text.eachLine { if (isFileNotAdded && it != null) { res = res + "name = ${it}\n" fileName = "/var/tmp/delivery/" + it file = new File(fileName) long size = file.size() //Initialize an instruction and add it to the software package //DownloadInstruction(String destinationDirectory, // File file, // String filename, // long originalFileSize, // boolean overwrite, // boolean execute, // boolean userCompressed, // CompressionType compressionType, // boolean deviceRelativePath) instruction = new DownloadInstruction( destinationDirectory, file, fileName, size, true, false, false, CompressionType.NONE, false) softwarePackageToUpdate.getInstructions().add(instruction) isFileNotAdded = false } } cmdProc.waitFor() RestartAgentInstruction restartAgentInstruction = new RestartAgentInstruction() softwarePackageToUpdate.getInstructions().add(restartAgentInstruction) res = res + "getInstructions = " + softwarePackageToUpdate.getInstructions().toString() + "\n" result = softwarePackageBridge.create(softwarePackageToUpdate) res = res + result.toString() + "\n" return ['Content-Type': 'text', 'Content': "${res}"] } catch (Exception ex) { return ['Content-Type': 'text', 'Content': "Exception: " + ex.getMessage()] }