提交 f4132a57 编写于 作者: S Stephen Connolly

refactor the save method so that it is available to all and null safe. also...

refactor the save method so that it is available to all and null safe. also added a readResolve to handle when null properties are deserialized
上级 abdbddb3
......@@ -91,13 +91,6 @@ public class ListView extends View implements Saveable {
this.owner = owner;
}
public void save() throws IOException {
// persistence is a part of the owner.
// due to the initialization timing issue, it can be null when this method is called.
if (owner!=null)
owner.save();
}
private Object readResolve() {
if(includeRegex!=null)
includePattern = Pattern.compile(includeRegex);
......
......@@ -148,10 +148,6 @@ public class TreeView extends View implements ViewGroup {
// noop
}
public void save() throws IOException {
owner.save();
}
public void doCreateView( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
checkPermission(View.CREATE);
views.add(View.create(req,rsp,this));
......
......@@ -130,6 +130,13 @@ public abstract class View extends AbstractModelObject implements AccessControll
this.owner = owner;
}
private Object readResolve() {
if (properties == null) {
properties = new ArrayList<ViewProperty>();
}
return this;
}
/**
* Gets all the items in this collection in a read-only view.
*/
......@@ -213,7 +220,15 @@ public abstract class View extends AbstractModelObject implements AccessControll
ps.add(p);
p.setView(this);
properties = ps;
owner.save();
save();
}
public void save() throws IOException {
// persistence is a part of the owner
// due to initialization timing issue, it can be null when this method is called
if (owner != null) {
owner.save();
}
}
/**
......@@ -615,7 +630,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
checkPermission(CONFIGURE);
description = req.getParameter("description");
owner.save();
save();
rsp.sendRedirect("."); // go to the top page
}
......@@ -658,7 +673,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
}
properties = props;
owner.save();
save();
rsp.sendRedirect2("../"+name);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册