if (rs == null || !rs.next()) {
logger.error("resource with id=" + id + " not found");
throw new DoesNotExistException();
}
final VirtualMachine vm =
VirtualMachinePersistenceUtil.newVM(id, rs);
if (this.dbTrace) {
logger.trace(Lager.id(id) +
", created vm:\n" + vm.toString());
}
rs.close();
rs = pstmts[1].executeQuery();
if (rs == null || !rs.next()) {
logger.debug("resource with id=" + id + " has no" +
" deployment information");
} else {
VirtualMachinePersistenceUtil.addDeployment(vm, rs);
if (this.dbTrace) {
logger.trace("added deployment info to vm object");
}
rs.close();
}
rs = pstmts[2].executeQuery();
if (rs == null || !rs.next()) {
logger.warn("resource with id=" + id + " has no" +
" partitions");
} else {
final ArrayList partitions = new ArrayList(8);
do {
partitions.add(VirtualMachinePersistenceUtil.
getPartition(rs));
} while (rs.next());
final VirtualMachinePartition[] parts =
(VirtualMachinePartition[]) partitions.toArray(
new VirtualMachinePartition[partitions.size()]);
vm.setPartitions(parts);
}
rs = pstmts[3].executeQuery();
if (rs == null || !rs.next()) {
if (this.lager.dbLog) {
logger.debug("resource with id=" + id + " has no" +
" customization needs");
}
} else {
do {
vm.addFileCopyNeed(
VirtualMachinePersistenceUtil.getNeed(rs));
} while (rs.next());
}
((VMPersistence)resource).setWorkspace(vm);