* @param baseTempPath used to write temp files for binary data,
* must not be used by other exports at the same time
*/
public void exportComplete(int ppid, OutputStream out, String baseTempPath) {
BASE64Encoder encoder = new BASE64Encoder();
ProjectExporter exporter = new ProjectExporter();
Document doc = exporter.createProjectDoc();
// int i = 0;
List<Plan> list = null;
try {
list = em.createQuery(
"select p from Plan p where p.planProperties.id = "
+ ppid).getResultList();
} catch (Exception e1) {
list = new ArrayList<Plan>();
FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR, "An error occured while generating the export file.");
log.error("Could not load planProperties: ", e1);
}
try {
if (list.size() != 1) {
FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
"Skipping the export of the plan with properties"+ppid+": Couldnt load.");
} else {
//log.debug("adding project "+p.getplanProperties().getName()+" to XML...");
String tempPath = baseTempPath;
File tempDir = new File(tempPath);
tempDir.mkdirs();
List<Integer> uploadIDs = new ArrayList<Integer>();
List<Integer> recordIDs = new ArrayList<Integer>();
try {
exporter.addProject(list.get(0), doc, uploadIDs, recordIDs);
writeBinaryObjects(recordIDs, uploadIDs, tempPath, encoder);
// perform XSLT transformation to get the DATA into the PLANS
XMLWriter writer = new XMLWriter(new FileOutputStream("/tmp/testout"+System.currentTimeMillis()+".xml"));
writer.write(doc);