String planIdentifier;
try {
planIdentifier = planManagement.reservePlanIdentifier();
} catch (Exception e) {
throw new PlanningException("Could not reserve Identifier.", e);
} catch (Throwable e) {
throw new PlanningException("Could not reserve Identifier.", e);
}
this.plan.getPlanProperties().setRepositoryIdentifier(planIdentifier);
saveWithoutModifyingPlanState();
String binarydataTempPath = OS.getTmpPath() + planIdentifier + "/";
File binarydataTempDir = new File(binarydataTempPath);
binarydataTempDir.mkdirs();
File planFile = new File(binarydataTempPath + "plan.xml");
try {
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(planFile));
projectExport.exportComplete(plan.getPlanProperties().getId(), out, binarydataTempPath);
out.flush();
out.close();
planManagement.deployPlan(planIdentifier, new FileInputStream(planFile));
} catch (Exception e) {
throw new PlanningException("Failed to generate plan.", e);
}
} finally {
OS.deleteDirectory(binarydataTempDir);
}
}