* @param jobId the job to purge
* @return the new list of completed jobs
*/
public JobInfos purgeCompletedJobForId(String jobId, File file) {
JobInfos completedJobInfos = getCompletedJobs(file);
synchronized (file) {
CopyOnWriteArrayList<JobInfo> jobList = new CopyOnWriteArrayList<JobInfo>();
if (completedJobInfos != null) {
jobList.addAll(completedJobInfos.getJobInfoList());
for (JobInfo jobInfo: jobList ) {
if (jobInfo.jobId.equals(jobId)) {
jobList.remove(jobInfo);
}
}
}
JobInfos jobInfos = new JobInfos();
// if (jobList.size() > 0) {
try {
if (jaxbContext == null)
jaxbContext = JAXBContext.newInstance(JobInfos.class);
jobInfos.setJobInfoList(jobList);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.marshal(jobInfos, file);
} catch (JAXBException e) {
throw new RuntimeException(adminStrings.getLocalString("error.purging.completed.job","Error purging completed job ", jobId,e.getLocalizedMessage()), e);
}