2

I'm trying to extract attachments from integrity PTC items that are on a linux server from my Windows PC but it keeps giving me errors. The exact same command worked in command line

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);

I'm getting an error that says

Error encountered trying to get the next name: File paths must be rooted in /export/home/ptc/Integrity/ILMServer11.0/data/tmp: Current file is /export/home/ptc/Integrity/ILMServer11.0/bin/C:\Workspace\document/bear.jpg

Anytime I add cwd to the command it just appends whatever I put after the /bin/ It says it's a InvalidCommandSelectionException and a CommandException

R Zol
  • 55
  • 5

1 Answers1

1

You're missing the outputFile option on the extractattachments command.

This code worked the way I expected it to ...

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();
David G
  • 3,940
  • 1
  • 22
  • 30