* Import all the latest Doap documents.
* @throws SimalException
* @throws IOException
*/
public void importLatestDOAP() throws SimalException, IOException {
ISimalRepository repo;
int preProjectCount;
repo = SimalRepositoryFactory.getInstance();
preProjectCount = repo.getAllProjects().size();
Document pings = getLatestPingsAsRDF();
OutputFormat format = new OutputFormat(pings);
StringWriter writer = new StringWriter();
XMLSerializer serial = new XMLSerializer(writer, format);
serial.serialize(pings);
logger.info("Updated DOAP documents:\n");
logger.info(writer.toString());
File tmpFile = new File(System.getProperty("java.io.tmpdir")
+ File.separator + "PTSWExport.xml");
FileWriter fw = null;
try {
fw = new FileWriter(tmpFile);
fw.write(writer.toString());
} catch (IOException e) {
throw new SimalException(
"Unable to write PTSW export file to temporary space");
} finally {
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
logger.warn("Unable to close file", e);
}
}
}
repo.addProject(tmpFile.toURI().toURL(), tmpFile.toURI().toURL()
.toExternalForm());
int postProjectCount = repo.getAllProjects().size();
logger.info("Imported " + (postProjectCount - preProjectCount)
+ " project records from PTSW");
}