Check for readonly flag in putProperty method so that write protected
properties can't be modified from script code. Deleted stuff that was permanently commented out: * setNode() method * readonly check for created and lastmodified props
This commit is contained in:
parent
4e192c39c0
commit
4a3879b0ee
1 changed files with 9 additions and 17 deletions
|
@ -89,21 +89,6 @@ public class ESNode extends ObjectPrototype {
|
|||
return node;
|
||||
}
|
||||
|
||||
/* public void setNode (INode node) {
|
||||
if (node != null) {
|
||||
this.node = node;
|
||||
// set node handle to wrapped node
|
||||
if (node instanceof helma.objectmodel.db.Node)
|
||||
handle = ((helma.objectmodel.db.Node) node).getHandle ();
|
||||
else
|
||||
handle = null;
|
||||
eval.objectcache.put (node, this);
|
||||
// reset cache Node - will be reinitialized when needed
|
||||
cache = null;
|
||||
cacheWrapper = null;
|
||||
}
|
||||
} */
|
||||
|
||||
public void setPrototype (String protoName) {
|
||||
checkNode ();
|
||||
node.setPrototype (protoName);
|
||||
|
@ -240,8 +225,7 @@ public class ESNode extends ObjectPrototype {
|
|||
public void putProperty(String propertyName, ESValue propertyValue, int hash) throws EcmaScriptException {
|
||||
checkNode ();
|
||||
// eval.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass());
|
||||
if (/* "lastmodified".equalsIgnoreCase (propertyName) || "created".equalsIgnoreCase (propertyName) || */
|
||||
"cache".equalsIgnoreCase (propertyName))
|
||||
if ("cache".equalsIgnoreCase (propertyName))
|
||||
throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\".");
|
||||
|
||||
if ("subnodeRelation".equalsIgnoreCase (propertyName)) {
|
||||
|
@ -249,6 +233,14 @@ public class ESNode extends ObjectPrototype {
|
|||
return;
|
||||
}
|
||||
|
||||
// check if the property is write protected, i.e. the type.property file describes it as [readonly]
|
||||
DbMapping dbm = node.getDbMapping ();
|
||||
if (dbm != null) {
|
||||
Relation rel = dbm.getPropertyRelation (propertyName);
|
||||
if (rel != null && rel.isReadonly ())
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyValue instanceof ESNull || propertyValue instanceof ESUndefined)
|
||||
node.unset (propertyName);
|
||||
else if (propertyValue instanceof ESString)
|
||||
|
|
Loading…
Add table
Reference in a new issue