如何使用 Java API 从完整性 PTC 项目中提取附件
how do I extract attachments from integrity PTC items using Java API
我正在尝试从我的 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 :\工作区\document/bear.jpg
每当我将 cwd 添加到命令时,它只会附加我在 /bin/ 之后放置的任何内容,它说这是一个 InvalidCommandSelectionException 和一个 CommandException
您在 extractattachments
命令中缺少 outputFile
选项。
此代码按我预期的方式工作...
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();
我正在尝试从我的 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 :\工作区\document/bear.jpg
每当我将 cwd 添加到命令时,它只会附加我在 /bin/ 之后放置的任何内容,它说这是一个 InvalidCommandSelectionException 和一个 CommandException
您在 extractattachments
命令中缺少 outputFile
选项。
此代码按我预期的方式工作...
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();