From 425fc68d0bc19a629ce549c84242e4a6bfa41883 Mon Sep 17 00:00:00 2001 From: Sylvain Cadilhac Date: Tue, 24 Sep 2024 00:51:41 +0200 Subject: [PATCH] fix(core): :bug: fix diagnostic execution --- .../onl/netfishers/netshot/device/Device.java | 2 +- .../device/attribute/ConfigAttribute.java | 2 +- .../attribute/ConfigBinaryAttribute.java | 2 +- .../attribute/ConfigBinaryFileAttribute.java | 2 +- .../attribute/ConfigLongTextAttribute.java | 2 +- .../attribute/ConfigNumericAttribute.java | 2 +- .../device/attribute/ConfigTextAttribute.java | 2 +- .../device/script/SnapshotCliScript.java | 2 +- .../diagnostic/DiagnosticBinaryResult.java | 20 ++++------------ .../diagnostic/DiagnosticLongTextResult.java | 23 ++++--------------- .../diagnostic/DiagnosticNumericResult.java | 20 ++++------------ .../netshot/diagnostic/DiagnosticResult.java | 17 ++++++++++++++ .../diagnostic/DiagnosticTextResult.java | 20 ++++------------ .../netfishers/netshot/rest/RestService.java | 4 +++- .../onl/netfishers/netshot/work/Task.java | 5 ++-- .../onl/netfishers/netshot/work/TaskJob.java | 17 ++++++++++---- .../work/tasks/CheckComplianceTask.java | 2 +- .../work/tasks/CheckGroupComplianceTask.java | 2 +- .../work/tasks/CheckGroupSoftwareTask.java | 2 +- .../work/tasks/DiscoverDeviceTypeTask.java | 2 +- .../work/tasks/RunDeviceGroupScriptTask.java | 3 ++- .../work/tasks/RunDeviceScriptTask.java | 2 +- .../work/tasks/RunDiagnosticsTask.java | 8 +++---- .../work/tasks/RunGroupDiagnosticsTask.java | 3 ++- .../work/tasks/TakeGroupSnapshotTask.java | 3 ++- .../netshot/work/tasks/TakeSnapshotTask.java | 3 +-- 26 files changed, 76 insertions(+), 96 deletions(-) diff --git a/src/main/java/onl/netfishers/netshot/device/Device.java b/src/main/java/onl/netfishers/netshot/device/Device.java index e7c05323..78cc0106 100644 --- a/src/main/java/onl/netfishers/netshot/device/Device.java +++ b/src/main/java/onl/netfishers/netshot/device/Device.java @@ -742,7 +742,7 @@ public void addDiagnosticResult(DiagnosticResult result) { while (existingIterator.hasNext()) { DiagnosticResult existingResult = existingIterator.next(); if (existingResult.getDiagnostic().equals(result.getDiagnostic())) { - if (result.equals(existingResult)) { + if (result.equals(existingResult) && result.valueEquals(existingResult)) { existingResult.setLastCheckDate(result.getLastCheckDate()); doAdd = false; } diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigAttribute.java index 56421bc8..96d9836e 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigAttribute.java @@ -95,7 +95,7 @@ public ConfigAttribute(Config config, String name) { @Transient public abstract Object getData(); - public abstract boolean deepEquals(ConfigAttribute other); + public abstract boolean valueEquals(ConfigAttribute other); @Override public int hashCode() { diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryAttribute.java index b6af707e..a57835da 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryAttribute.java @@ -65,7 +65,7 @@ public Object getData() { } @Override - public boolean deepEquals(ConfigAttribute obj) { + public boolean valueEquals(ConfigAttribute obj) { if (this == obj) return true; if (!(obj instanceof ConfigBinaryAttribute)) diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryFileAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryFileAttribute.java index b13c9f7a..f28ff7fd 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryFileAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigBinaryFileAttribute.java @@ -95,7 +95,7 @@ public Object getData() { } @Override - public boolean deepEquals(ConfigAttribute obj) { + public boolean valueEquals(ConfigAttribute obj) { if (this == obj) return true; if (!(obj instanceof ConfigBinaryFileAttribute)) diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigLongTextAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigLongTextAttribute.java index b04ce991..fab9827b 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigLongTextAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigLongTextAttribute.java @@ -69,7 +69,7 @@ public Object getData() { } @Override - public boolean deepEquals(ConfigAttribute obj) { + public boolean valueEquals(ConfigAttribute obj) { if (this == obj) return true; if (!(obj instanceof ConfigLongTextAttribute)) diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigNumericAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigNumericAttribute.java index 30879e2a..58f4c16b 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigNumericAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigNumericAttribute.java @@ -63,7 +63,7 @@ public Object getData() { } @Override - public boolean deepEquals(ConfigAttribute obj) { + public boolean valueEquals(ConfigAttribute obj) { if (this == obj) return true; if (!(obj instanceof ConfigNumericAttribute)) diff --git a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigTextAttribute.java b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigTextAttribute.java index f6c9ab4b..c615224a 100644 --- a/src/main/java/onl/netfishers/netshot/device/attribute/ConfigTextAttribute.java +++ b/src/main/java/onl/netfishers/netshot/device/attribute/ConfigTextAttribute.java @@ -63,7 +63,7 @@ public Object getData() { } @Override - public boolean deepEquals(ConfigAttribute obj) { + public boolean valueEquals(ConfigAttribute obj) { if (this == obj) return true; if (!(obj instanceof ConfigTextAttribute)) diff --git a/src/main/java/onl/netfishers/netshot/device/script/SnapshotCliScript.java b/src/main/java/onl/netfishers/netshot/device/script/SnapshotCliScript.java index 2ac0983b..b26a6995 100644 --- a/src/main/java/onl/netfishers/netshot/device/script/SnapshotCliScript.java +++ b/src/main/java/onl/netfishers/netshot/device/script/SnapshotCliScript.java @@ -105,7 +105,7 @@ protected void run(Session session, Device device, Cli cli, Snmp snmp, DriverPro ConfigAttribute oldAttribute = oldAttributes.get(definition.getName()); ConfigAttribute newAttribute = newAttributes.get(definition.getName()); if (oldAttribute != null) { - if (!oldAttribute.deepEquals(newAttribute)) { + if (!oldAttribute.valueEquals(newAttribute)) { different = true; break; } diff --git a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticBinaryResult.java b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticBinaryResult.java index 496098ff..54301e72 100644 --- a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticBinaryResult.java +++ b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticBinaryResult.java @@ -23,6 +23,8 @@ import jakarta.persistence.Transient; import jakarta.xml.bind.annotation.XmlElement; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonView; import lombok.Getter; @@ -73,27 +75,13 @@ public Object getData() { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((assumption == null) ? 0 : assumption.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { + public boolean valueEquals(DiagnosticResult obj) { if (this == obj) return true; if (!(obj instanceof DiagnosticBinaryResult)) return false; DiagnosticBinaryResult other = (DiagnosticBinaryResult) obj; - if (assumption == null) { - if (other.assumption != null) - return false; - } - else if (!assumption.equals(other.assumption)) - return false; - return true; + return Objects.equals(this.assumption, other.assumption); } } diff --git a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticLongTextResult.java b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticLongTextResult.java index 866300c1..9fa5836e 100644 --- a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticLongTextResult.java +++ b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticLongTextResult.java @@ -21,10 +21,11 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; import jakarta.persistence.OneToOne; import jakarta.persistence.Transient; +import java.util.Objects; + import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; @@ -37,7 +38,7 @@ public class DiagnosticLongTextResult extends DiagnosticResult { @Getter(onMethod=@__({ - @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY), + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true), @OnDelete(action = OnDeleteAction.CASCADE) })) @Setter @@ -70,27 +71,13 @@ public Object getData() { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((longText == null) ? 0 : longText.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { + public boolean valueEquals(DiagnosticResult obj) { if (this == obj) return true; if (!(obj instanceof DiagnosticLongTextResult)) return false; DiagnosticLongTextResult other = (DiagnosticLongTextResult) obj; - if (longText == null) { - if (other.longText != null) - return false; - } - else if (!longText.equals(other.longText)) - return false; - return true; + return Objects.equals(this.longText, other.longText); } } diff --git a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticNumericResult.java b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticNumericResult.java index 43413af9..82e810ed 100644 --- a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticNumericResult.java +++ b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticNumericResult.java @@ -23,6 +23,8 @@ import jakarta.persistence.Transient; import jakarta.xml.bind.annotation.XmlElement; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonView; import lombok.Getter; @@ -68,27 +70,13 @@ public Object getData() { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((number == null) ? 0 : number.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { + public boolean valueEquals(DiagnosticResult obj) { if (this == obj) return true; if (!(obj instanceof DiagnosticNumericResult)) return false; DiagnosticNumericResult other = (DiagnosticNumericResult) obj; - if (number == null) { - if (other.number != null) - return false; - } - else if (!number.equals(other.number)) - return false; - return true; + return Objects.equals(this.number, other.number); } } diff --git a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticResult.java b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticResult.java index eb3fc471..d4529792 100644 --- a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticResult.java +++ b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticResult.java @@ -19,6 +19,7 @@ package onl.netfishers.netshot.diagnostic; import java.util.Date; +import java.util.Objects; import jakarta.persistence.DiscriminatorColumn; import jakarta.persistence.DiscriminatorType; @@ -145,4 +146,20 @@ public String getDiagnosticName() { return this.getDiagnostic().getName(); } + public abstract boolean valueEquals(DiagnosticResult obj); + + @Override + public int hashCode() { + return Objects.hash(diagnostic, device); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof DiagnosticResult)) return false; + DiagnosticResult other = (DiagnosticResult) obj; + return Objects.equals(diagnostic, other.diagnostic) + && Objects.equals(device, other.device); + } + } diff --git a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticTextResult.java b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticTextResult.java index c22b1a30..919a002e 100644 --- a/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticTextResult.java +++ b/src/main/java/onl/netfishers/netshot/diagnostic/DiagnosticTextResult.java @@ -24,6 +24,8 @@ import jakarta.persistence.Transient; import jakarta.xml.bind.annotation.XmlElement; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonView; import lombok.Getter; @@ -65,27 +67,13 @@ public Object getData() { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((text == null) ? 0 : text.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { + public boolean valueEquals(DiagnosticResult obj) { if (this == obj) return true; if (!(obj instanceof DiagnosticTextResult)) return false; DiagnosticTextResult other = (DiagnosticTextResult) obj; - if (text == null) { - if (other.text != null) - return false; - } - else if (!text.equals(other.text)) - return false; - return true; + return Objects.equals(this.text, other.text); } } diff --git a/src/main/java/onl/netfishers/netshot/rest/RestService.java b/src/main/java/onl/netfishers/netshot/rest/RestService.java index 4a09f143..60e16728 100644 --- a/src/main/java/onl/netfishers/netshot/rest/RestService.java +++ b/src/main/java/onl/netfishers/netshot/rest/RestService.java @@ -9039,7 +9039,9 @@ public List getDeviceDiagnosticResults(@BeanParam PaginationPa Session session = Database.getSession(true); try { Query query = session - .createQuery("from DiagnosticResult dr join fetch dr.diagnostic where dr.device.id = :id", DiagnosticResult.class) + .createQuery( + "from DiagnosticResult dr join fetch dr.diagnostic where dr.device.id = :id", + DiagnosticResult.class) .setParameter("id", id); paginationParams.apply(query); return query.list(); diff --git a/src/main/java/onl/netfishers/netshot/work/Task.java b/src/main/java/onl/netfishers/netshot/work/Task.java index e3038c1b..cb8c3bcc 100644 --- a/src/main/java/onl/netfishers/netshot/work/Task.java +++ b/src/main/java/onl/netfishers/netshot/work/Task.java @@ -58,6 +58,7 @@ import onl.netfishers.netshot.work.tasks.TakeGroupSnapshotTask; import onl.netfishers.netshot.work.tasks.TakeSnapshotTask; +import org.hibernate.Session; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; import org.quartz.JobKey; @@ -492,8 +493,8 @@ public void onSchedule() { /** * Prepare. */ - public void prepare() { - + public void prepare(Session session) { + // Override to actually do something } /** diff --git a/src/main/java/onl/netfishers/netshot/work/TaskJob.java b/src/main/java/onl/netfishers/netshot/work/TaskJob.java index b6835f49..2e38a9de 100644 --- a/src/main/java/onl/netfishers/netshot/work/TaskJob.java +++ b/src/main/java/onl/netfishers/netshot/work/TaskJob.java @@ -74,20 +74,27 @@ public void execute(JobExecutionContext context) throws JobExecutionException { task.setRunning(); log.trace("The task runner ID for {} is {}", task.getId(), task.getRunnerId()); session.merge(task); - session.getTransaction().commit(); log.trace("Got the task."); - task.prepare(); + task.prepare(session); log.trace("The task has prepared its fields."); + session.getTransaction().commit(); } catch (Exception e) { - log.error("Error while retrieving and updating the task.", e); + log.error("Error while retrieving, updating or preparing the task.", e); try { session.getTransaction().rollback(); + session.beginTransaction(); + Task eTask = (Task) session.get(Task.class, id); + eTask.setRunning(); + eTask.setFailed(); + eTask.setLog(e.getMessage()); + session.merge(eTask); + session.getTransaction().commit(); } catch (Exception e1) { } - throw new JobExecutionException("Unable to access the task."); + throw new JobExecutionException("Unable to access or prepare the task."); } finally { session.close(); @@ -103,7 +110,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { if (task.getStatus() == Status.RUNNING) { log.error("The task {} exited with a status of RUNNING.", id); - task.setStatus(Status.FAILURE); + task.setFailed(); } log.trace("Updating the task with the result."); diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/CheckComplianceTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/CheckComplianceTask.java index 8eb443bd..391091e5 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/CheckComplianceTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/CheckComplianceTask.java @@ -84,7 +84,7 @@ public CheckComplianceTask(Device device, String comments, String author) { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(device); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupComplianceTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupComplianceTask.java index cb52c520..c2e2ae45 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupComplianceTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupComplianceTask.java @@ -96,7 +96,7 @@ public String getTaskDescription() { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDeviceGroup()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupSoftwareTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupSoftwareTask.java index 296cdd95..b4148dc2 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupSoftwareTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/CheckGroupSoftwareTask.java @@ -98,7 +98,7 @@ public String getTaskDescription() { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDeviceGroup()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/DiscoverDeviceTypeTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/DiscoverDeviceTypeTask.java index f588987b..02351a9d 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/DiscoverDeviceTypeTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/DiscoverDeviceTypeTask.java @@ -277,7 +277,7 @@ private boolean snmpv3Discover(DeviceSnmpv3Community cred) { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getCredentialSets()); this.getDomain().getId(); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceGroupScriptTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceGroupScriptTask.java index 65ec331a..5a83e1b5 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceGroupScriptTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceGroupScriptTask.java @@ -41,6 +41,7 @@ import onl.netfishers.netshot.work.Task; import org.hibernate.Hibernate; +import org.hibernate.Session; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; @@ -108,7 +109,7 @@ public String getTaskDescription() { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDeviceGroup()); Hibernate.initialize(this.getDeviceGroup().getCachedDevices()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceScriptTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceScriptTask.java index ffcb8c69..2164c2c7 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceScriptTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/RunDeviceScriptTask.java @@ -105,7 +105,7 @@ public RunDeviceScriptTask(Device device, String script, DeviceDriver driver, St } @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDevice()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/RunDiagnosticsTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/RunDiagnosticsTask.java index 156a1eb3..b745bf32 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/RunDiagnosticsTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/RunDiagnosticsTask.java @@ -101,9 +101,8 @@ public RunDiagnosticsTask(Device device, String comments, String author, boolean * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { - Hibernate.initialize(device); - Hibernate.initialize(device.getDiagnosticResults()); + public void prepare(Session session) { + Hibernate.initialize(this.device); } @Override @@ -163,7 +162,8 @@ public void run() { } List diagnostics = session.createQuery( - "select distinct dg from Diagnostic dg where dg.enabled = :enabled and dg.targetGroup in (select g from Device d join d.ownerGroups g where d = :device)", + "select distinct dg from Diagnostic dg where dg.enabled = :enabled and " + + "dg.targetGroup in (select g from Device d join d.ownerGroups g where d = :device)", Diagnostic.class) .setParameter("device", device) .setParameter("enabled", true) diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/RunGroupDiagnosticsTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/RunGroupDiagnosticsTask.java index ee756ad8..c85a087c 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/RunGroupDiagnosticsTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/RunGroupDiagnosticsTask.java @@ -39,6 +39,7 @@ import onl.netfishers.netshot.work.Task; import org.hibernate.Hibernate; +import org.hibernate.Session; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; import org.quartz.JobKey; @@ -101,7 +102,7 @@ public String getTaskDescription() { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDeviceGroup()); Hibernate.initialize(this.getDeviceGroup().getCachedDevices()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/TakeGroupSnapshotTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/TakeGroupSnapshotTask.java index 4c0ae1d0..c4f3504b 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/TakeGroupSnapshotTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/TakeGroupSnapshotTask.java @@ -40,6 +40,7 @@ import onl.netfishers.netshot.work.Task; import org.hibernate.Hibernate; +import org.hibernate.Session; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; import org.quartz.JobKey; @@ -121,7 +122,7 @@ public String getTaskDescription() { * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDeviceGroup()); Hibernate.initialize(this.getDeviceGroup().getCachedDevices()); } diff --git a/src/main/java/onl/netfishers/netshot/work/tasks/TakeSnapshotTask.java b/src/main/java/onl/netfishers/netshot/work/tasks/TakeSnapshotTask.java index 8b9d9386..8c9e1bd9 100644 --- a/src/main/java/onl/netfishers/netshot/work/tasks/TakeSnapshotTask.java +++ b/src/main/java/onl/netfishers/netshot/work/tasks/TakeSnapshotTask.java @@ -185,9 +185,8 @@ public TakeSnapshotTask(Device device, String comments, String author, boolean a * @see onl.netfishers.netshot.work.Task#prepare() */ @Override - public void prepare() { + public void prepare(Session session) { Hibernate.initialize(this.getDevice()); - Hibernate.initialize(this.getDevice().getLastConfig()); } /* (non-Javadoc)