Commit dd3596e2 authored by Mathijs den Burger's avatar Mathijs den Burger

HSTCONFIGEDIT-169: retrieve bean only once if possible

parent 3ab6d471
......@@ -77,7 +77,6 @@ public abstract class BasicEditorPlugin<K extends EditorBean> extends EditorPlug
@Override
protected void onDetach() {
super.onDetach();
final K object = getObject();
if (object != null) {
object.detach();
......@@ -216,16 +215,18 @@ public abstract class BasicEditorPlugin<K extends EditorBean> extends EditorPlug
}
protected void doSave() {
if (dao.save(getBean())) {
setDefaultModel(getBean().getModel());
final K bean = getBean();
if (dao.save(bean)) {
setDefaultModel(bean.getModel());
info(getString("save.succes"));
}
}
protected void doRemove() {
final K bean = getBean();
try {
final String name = getBean().getModel().getNode().getName();
Node next = getBean().getModel().getParentModel().getNode();
final String name = bean.getModel().getNode().getName();
Node next = bean.getModel().getParentModel().getNode();
for (NodeIterator it = next.getNodes(); it.hasNext();) {
Node node = it.nextNode();
......@@ -239,12 +240,12 @@ public abstract class BasicEditorPlugin<K extends EditorBean> extends EditorPlug
}
}
if (dao.delete(getBean())) {
if (dao.delete(bean)) {
setDefaultModel(new JcrNodeModel(next));
info(new StringResourceModel("node.removed", this, null, new Object[] { name }).getString());
}
} catch (RepositoryException e) {
log.error("Failed to remove node, model = " + getBean().getModel());
log.error("Failed to remove node, model = " + bean.getModel());
}
}
......@@ -255,7 +256,7 @@ public abstract class BasicEditorPlugin<K extends EditorBean> extends EditorPlug
@Override
public void detachModels() {
nodeSort.detach();
if(beanModel != null) {
if (beanModel != null) {
beanModel.detach();
}
super.detachModels();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment