2

我正在尝试从我的 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

4

1 回答 1

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();
于 2018-04-06T19:19:49.653 回答