use of fi.otavanopisto.muikku.plugins.workspace.events.WorkspaceMaterialDeleteEvent in project muikku by otavanopisto.
the class WorkspaceMaterialController method deleteWorkspaceMaterial.
public void deleteWorkspaceMaterial(WorkspaceMaterial workspaceMaterial, boolean removeAnswers) throws WorkspaceMaterialContainsAnswersExeption {
try {
workspaceMaterialDeleteEvent.fire(new WorkspaceMaterialDeleteEvent(workspaceMaterial, removeAnswers));
List<WorkspaceNode> childNodes = workspaceNodeDAO.listByParentSortByOrderNumber(workspaceMaterial);
for (WorkspaceNode childNode : childNodes) {
if (childNode instanceof WorkspaceMaterial) {
deleteWorkspaceMaterial((WorkspaceMaterial) childNode, removeAnswers);
} else if (childNode instanceof WorkspaceFolder) {
deleteWorkspaceFolder((WorkspaceFolder) childNode);
}
}
} catch (Exception e) {
Throwable cause = e;
while (cause != null) {
cause = cause.getCause();
if (cause instanceof WorkspaceMaterialContainsAnswersExeption) {
throw (WorkspaceMaterialContainsAnswersExeption) cause;
}
}
throw e;
}
workspaceMaterialDAO.delete(workspaceMaterial);
}
Aggregations