@Override public Result execute(ChainContext cc) { try { StoreItem storeItem = (StoreItem) cc.getAttribute(CommandsConstants.STORE_ITEM); File appDir = (File) cc.getAttribute(CommandsConstants.APP_DIR); String itemId = (String) cc.getAttribute(CommandsConstants.ITEM_ID); String fileName = (String) cc.getAttribute(CommandsConstants.DOWNLOADED_FILE_NAME); String username = itemId; String password = StringUtil.getRandom(8); Properties prop = Prefs.load(appDir); boolean internalDeployRequested = false; for (String ftp : storeItem.publishFtp) { if (ftp.equals("ftp:")) internalDeployRequested = true; } if (prop.getProperty("publish.local.ftp.enable").equals("true") || internalDeployRequested == true) { File fromFile = new File(prop.getProperty("download.dir"), itemId); File userRoot = new File(prop.getProperty("publish.local.ftp.rootdir"), username); File toFile = new File(userRoot, fileName); userRoot.mkdirs(); IOUtil.copyFile(fromFile, toFile); FTPService ftpServer; ftpServer = FTPService.getInstance(); ftpServer.addUser(username, password, userRoot.getAbsolutePath()); String url; url = "ftp://" + username + ":" + password + "@" + prop.getProperty("publish.local.ftp.ip") + ":" + prop.getProperty("publish.local.ftp.port") + "/" + fileName; FTPAccessible.add(itemId, url); } } catch (Exception e) { Log.logException(e); return new Result(Result.FAIL); } return new Result(Result.SUCCESS); }