我试图从我的Windows PC上提取Linux服务器上的完整性PTC项目的附件,但它一直给我错误。完全相同的命令在命令行中工作
IntegrationPoint integrationPoint =
IntegrationPointFactory.getInstance().createIntegrationPoint(
hostName,
port,
APIVersion.API_4_16);
System.out.println("Start download Attachment");
// Start the Integrity client.
integrationPoint.setAutoStartIntegrityClient(true);
// Connect to the Integrity server.
Session session = integrationPoint.createSession(username, password);
Command command = new Command(Command.IM, "extractattachments");
command.addOption(new Option("issue", itemID));
command.addOption(new Option("field", "Text Attachments"));
command.addSelection(attachment);
Response response = session.createCmdRunner().execute(command);
我收到错误消息
尝试获取下一个名称时遇到错误:文件路径必须植根于/export/home/ptc/Integrity/ILMServer11.0/data/tmp:当前文件为/export/home/ptc/Integrity/ILMServer11.0 /bin/C:\Workspace\document/bear.jpg
无论何时我将cwd添加到命令中它只是附加我在/ bin之后放置的内容它说它是InvalidCommandSelectionException和CommandException
答案 0 :(得分:1)
您错过了outputFile
命令中的extractattachments
选项。
这段代码按我预期的方式工作......
IntegrationPointFactory ipfact = IntegrationPointFactory.getInstance();
IntegrationPoint ip = ipfact.createIntegrationPoint(hostname, port, APIVersion.API_4_16);
Session session = ip.createNamedSession("test", APIVersion.API_4_16, user, passwd);
CmdRunner cr = session.createCmdRunner();
Command cmd = new Command(Command.IM, "extractattachments");
cmd.addSelection(attachmentName);
cmd.addOption(new Option("issue", issueid));
cmd.addOption(new FileOption("outputFile", "d:/data/" + attachmentName));
cr.execute(cmd);
cr.release();
ip.release();