diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2013-12-12 14:13:36 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2013-12-12 14:13:36 +0100 |
| commit | 428d828ca640d1348979f9982d1c0bc0a489a3b4 (patch) | |
| tree | a40b0f8fa46942f5e9d4c805a4df724ee5a5aa6b | |
| parent | d5d65f58e69424d898f88e8304a49f147d4036f6 (diff) | |
Properties preserve and respect the PropertyDescription 'isMutable'
property. This setting prevents the WriteProperty predefined step from
changing the property value when isMutable is false. WriteProperty also
requires the selected property to already exist - they should be created
either during Item instantiation or using AddC2KObject.
LDAPPropertyManager prepends the Property name in its entries with ! if
they are non mutable.
Various places around the kernel that create properties now set the
mutable field.
Fixes #150
17 files changed, 107 insertions, 145 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java index ceea6c3..0e6859d 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java @@ -79,7 +79,7 @@ public class ItemProxy extends EntityProxy public void setProperty(AgentProxy agent, String name, String value)
throws AccessRightsException,
- PersistencyException
+ PersistencyException, InvalidDataException
{
String[] params = new String[2];
params[0] = name;
@@ -90,9 +90,11 @@ public class ItemProxy extends EntityProxy throw (e);
} catch (PersistencyException e) {
throw (e);
+ } catch (InvalidDataException e) {
+ throw (e);
} catch (Exception e) {
Logger.error(e);
- throw new PersistencyException("Could not store property");
+ throw new PersistencyException("Could not store property", "");
}
}
/**************************************************************************
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java index 10e54d1..3197ce5 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java @@ -128,8 +128,8 @@ public class CreateItemFromDescription extends PredefinedStep prop.setValue(newName);
}
}
- if (!foundName) props.list.add(new Property("Name", newName));
- props.list.add( new Property("Creator", agent.getAgentName()));
+ if (!foundName) props.list.add(new Property("Name", newName, true));
+ props.list.add( new Property("Creator", agent.getAgentName(), false));
/* ITEM CREATION */
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java index 1eef4f5..abb0e95 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java @@ -12,7 +12,10 @@ package com.c2kernel.lifecycle.instance.predefined;
import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
import com.c2kernel.property.Property;
import com.c2kernel.utils.Logger;
@@ -38,24 +41,30 @@ public class WriteProperty extends PredefinedStep int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "WriteProperty::request() - Starting.");
-
String[] params = getDataList(requestData);
+
if (params.length != 2)
- throw new InvalidDataException("WriteProperty::request() - need 2 params - name and value", "");
- try
- {
-
- Logger.msg(5, "WriteProperty::request() - name:" + params[0] +" val:"+params[1]);
-
- Property newProp = new Property(params[0], params[1]);
- Gateway.getStorage().put(itemSysKey, newProp, null );
- }
- catch( Exception ex )
- {
- Logger.error("WriteProperty::request() - during unmarshall.");
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
- }
+ throw new InvalidDataException("WriteProperty usage: [ name, value ]", "");
+
+ Logger.msg(5, "WriteProperty::request() - name:" + params[0] +" val:"+params[1]);
+
+ String name = params[0];
+ String newValue = params[1];
+
+ Property prop;
+
+ try {
+ prop = (Property)Gateway.getStorage().get(itemSysKey, ClusterStorage.PROPERTY+"/"+name, null);
+ if (!prop.isMutable() && !newValue.equals(prop.getValue()))
+ throw new InvalidDataException("Property '"+name+"' is not mutable.", "");
+ prop.setValue(newValue);
+ Gateway.getStorage().put(itemSysKey, prop, null);
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidDataException("WriteProperty: Property '"+name+"' not found.", "");
+ } catch (ClusterStorageException e) {
+ Logger.error(e);
+ throw new InvalidDataException("Storage error. See logs.", "");
+ }
Logger.msg(1, "WriteProperty::request() - DONE.");
return requestData;
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java index e7301a1..12bbb56 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java @@ -38,8 +38,8 @@ public class NewAgent extends ModuleImport implements java.io.Serializable { ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent);
Gateway.getLDAPLookup().add(newAgent);
// assemble properties
- properties.add(new com.c2kernel.property.Property("Name", name));
- properties.add(new com.c2kernel.property.Property("Type", "Agent"));
+ properties.add(new com.c2kernel.property.Property("Name", name, true));
+ properties.add(new com.c2kernel.property.Property("Type", "Agent", false));
try {
newAgentEnt.initialise(Gateway.getMarshaller().marshall(new PropertyArrayList(properties)));
} catch (Exception ex) {
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index dacb1a3..d5da008 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -80,7 +80,7 @@ public class NewItem extends ModuleImport { }
// set the name property
- properties.add(new Property("Name", name));
+ properties.add(new Property("Name", name, true));
// init the new item
try {
diff --git a/src/main/java/com/c2kernel/lookup/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/LDAPLookup.java index 996ca0e..23d30d4 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/LDAPLookup.java @@ -45,7 +45,7 @@ public class LDAPLookup private LDAPConnection mLDAPConn;
private final LDAPProperties mLDAPProps;
private final NextKeyManager mNextKeyManager;
- private LDAPPropertyManager mPropManager;
+ private final LDAPPropertyManager mPropManager;
private final LDAPRoleManager mRoleManager;
@@ -73,14 +73,7 @@ public class LDAPLookup mNextKeyManager = new NextKeyManager(this, "cn=last,"+EntityPath.mTypeRoot);
Logger.msg(7, "LDAP.useOldProps="+Gateway.getProperty("LDAP.useOldProps", "false"));
- if (Gateway.getProperty("LDAP.useOldProps", "false").equals("true")) {
- Logger.debug(1, "Using Kernel 2.1 LDAP Property Format");
- mPropManager = new LegacyLDAPPropertyManager(this);
- }
- else {
- Logger.debug(1, "Using Kernel 2.2 LDAP Property Format");
- mPropManager = new LDAPPropertyManager(this);
- }
+ mPropManager = new LDAPPropertyManager(this);
mRoleManager = new LDAPRoleManager(this, "cn=agent,"+DomainPath.mTypeRoot, EntityPath.mTypeRoot);
}
diff --git a/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java b/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java index 57ed17d..fcf1ef8 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java +++ b/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java @@ -51,7 +51,9 @@ public class LDAPPropertyManager { LDAPAttribute props = entityEntry.getAttribute("cristalprop");
for (Enumeration<?> e = props.getStringValues(); e.hasMoreElements();) {
String thisProp = (String)e.nextElement();
- propbag.add(thisProp.substring(0, thisProp.indexOf(':')));
+ String thisName = thisProp.substring(0, thisProp.indexOf(':'));
+ if (thisName.startsWith("!") && thisName.length()>1) thisName = thisName.substring(1);
+ propbag.add(thisName);
}
String[] retArr = new String[props.size()];
@@ -61,12 +63,12 @@ public class LDAPPropertyManager { /**
* @param thisEntity - EntityPath of the subject entity
* @param propName - the name of the property to retrieve
- * @return String the property value
+ * @return The Property object
* @throws ObjectNotFoundException
*/
- public String getPropertyValue(EntityPath thisEntity, String name) throws ObjectNotFoundException {
+ public Property getProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException {
LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN());
- return getPropertyAttr(entityEntry, name);
+ return getProperty(entityEntry, name);
}
/**
@@ -77,9 +79,13 @@ public class LDAPPropertyManager { */
public void deleteProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated {
LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN());
- String propVal = getPropertyAttr(entityEntry, name);
+ Property prop = getProperty(entityEntry, name);
Logger.msg(6, "LDAPLookupUtils.deleteProperty("+name+") - Deleting property");
- LDAPLookupUtils.removeAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", name+":"+propVal);
+ LDAPLookupUtils.removeAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", getPropertyAttrValue(prop));
+ }
+
+ private static String getPropertyAttrValue(Property prop) {
+ return (prop.isMutable()?"":"!")+prop.getName()+":"+prop.getValue();
}
/**
@@ -91,28 +97,42 @@ public class LDAPPropertyManager { public void setProperty(EntityPath thisEntity, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated {
LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN());
try {
- String propVal = getPropertyAttr(entityEntry, prop.getName());
- Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - Removing old value '"+propVal+"'");
- LDAPLookupUtils.removeAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", prop.getName()+":"+propVal);
+ Property oldProp = getProperty(entityEntry, prop.getName());
+ Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - Removing old value '"+oldProp.getValue()+"'");
+ LDAPLookupUtils.removeAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", getPropertyAttrValue(oldProp));
} catch (ObjectNotFoundException ex) {
Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - creating new property.");
}
Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - setting to '"+prop.getValue()+"'");
- LDAPLookupUtils.addAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", prop.getName()+":"+prop.getValue());
+ LDAPLookupUtils.addAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", getPropertyAttrValue(prop));
}
- private static String getPropertyAttr(LDAPEntry myEntry, String propName) throws ObjectNotFoundException {
+ public static Property getProperty(LDAPEntry myEntry, String propName) throws ObjectNotFoundException {
// delete existing props
LDAPAttribute props = myEntry.getAttribute("cristalprop");
if (props == null)
throw new ObjectNotFoundException("Property "+propName+" does not exist", "");
String propPrefix = propName+":";
- for (Enumeration<?> e = props.getStringValues(); e.hasMoreElements();) {
- String val = (String)e.nextElement();
- if (val.toLowerCase().startsWith(propPrefix.toLowerCase()))
- return val.substring(propPrefix.length());
+ String roPropPrefix = "!"+propPrefix;
+ String val = null, name = null; boolean mutable = false;
+ for (Enumeration<?> e = props.getStringValues(); name==null && e.hasMoreElements();) {
+ String attrVal = (String)e.nextElement();
+ if (attrVal.toLowerCase().startsWith(propPrefix.toLowerCase())) {
+ name = attrVal.substring(0, propPrefix.length()-1);
+ val = attrVal.substring(propPrefix.length());
+ mutable = true; break;
+ }
+
+ if (attrVal.toLowerCase().startsWith(roPropPrefix.toLowerCase())) {
+ name = attrVal.substring(1, roPropPrefix.length()-1);
+ val = attrVal.substring(roPropPrefix.length());
+ mutable = false; break;
+ }
}
- throw new ObjectNotFoundException("Property "+propName+" does not exist", "");
+ if (name == null)
+ throw new ObjectNotFoundException("Property "+propName+" does not exist", "");
+ Logger.msg(6, "Loaded "+(mutable?"":"Non-")+"Mutable Property: "+name+"="+val);
+ return new Property(name, val, mutable);
}
}
diff --git a/src/main/java/com/c2kernel/lookup/LegacyLDAPPropertyManager.java b/src/main/java/com/c2kernel/lookup/LegacyLDAPPropertyManager.java deleted file mode 100644 index 638c694..0000000 --- a/src/main/java/com/c2kernel/lookup/LegacyLDAPPropertyManager.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.c2kernel.lookup;
-
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.property.Property;
-import com.c2kernel.utils.Logger;
-import com.novell.ldap.LDAPAttribute;
-import com.novell.ldap.LDAPAttributeSet;
-import com.novell.ldap.LDAPDN;
-import com.novell.ldap.LDAPEntry;
-import com.novell.ldap.LDAPException;
-
-public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
-
- public LegacyLDAPPropertyManager(LDAPLookup ldap) {
- super(ldap);
- }
-
- @Override
- public void deleteProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated {
- try {
- LDAPLookupUtils.delete(ldap.getConnection(), "cn="+name+","+thisEntity.getFullDN());
- } catch (LDAPException ex) {
- Logger.error("Error deleting prop "+name+" from "+thisEntity.getSysKey());
- Logger.error(ex);
- }
- }
-
- @Override
- public String[] getPropertyNames(EntityPath thisEntity) throws ObjectNotFoundException {
- String props[]= LDAPLookupUtils.getChildrenDNs(ldap.getConnection(), thisEntity.getFullDN(), "objectclass=cristalproperty");
- String names[] = new String[props.length];
- for (int i=0; i<props.length;i++)
- names[i] = new String(LDAPDN.explodeDN(props[i],true)[0]);
- return names;
- }
-
- @Override
- public String getPropertyValue(EntityPath thisEntity, String name) throws ObjectNotFoundException {
- LDAPEntry anEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),"cn="+name+","+thisEntity.getFullDN());
- if (anEntry==null)
- throw new ObjectNotFoundException("LDAPLookup: Property "+name+" not found in "+thisEntity.getSysKey(), "");
- return LDAPLookupUtils.getFirstAttributeValue(anEntry,"propval");
- }
-
- @Override
- public boolean hasProperties(EntityPath thisEntity) throws ObjectNotFoundException {
- return LDAPLookupUtils.hasChildren(ldap.getConnection(), thisEntity.getFullDN(), "objectclass=cristalproperty" );
- }
-
- @Override
- public void setProperty(EntityPath thisEntity, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated {
- try {
- LDAPEntry anEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),"cn="+prop.getName()+","+thisEntity.getFullDN());
- String currentVal = LDAPLookupUtils.getFirstAttributeValue(anEntry,"propval");
- if (currentVal == null || !currentVal.equals(prop.getValue()) )
- //change the propvalue if the prop.getValue() is not the same value in LDAP
- LDAPLookupUtils.setAttributeValue(ldap.getConnection(), anEntry,"propval",prop.getValue());
-
- } catch (ObjectNotFoundException ex) {
- LDAPAttributeSet attrSet = new LDAPAttributeSet();
- attrSet.add(new LDAPAttribute("objectclass","cristalproperty"));
- attrSet.add(new LDAPAttribute("cn",prop.getName()));
- if (prop.getValue()!=null && prop.getValue().length()!=0)
- attrSet.add(new LDAPAttribute("propval",prop.getValue()));
- LDAPEntry newEntry = new LDAPEntry("cn="+prop.getName()+","+thisEntity.getFullDN(),attrSet);
- try {
- LDAPLookupUtils.addEntry(ldap.getConnection(),newEntry);
- } catch (Exception e) {
- Logger.error(e);
- throw new ObjectCannotBeUpdated(e.getMessage(), "");
- }
- }
- }
-}
diff --git a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java index 16ac7a0..5a305f9 100644 --- a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java @@ -65,10 +65,7 @@ public class LDAPClusterStorage extends ClusterStorage { if (type.equals(PROPERTY)) {
try {
- String value = ldapStore.getPropertyValue(thisEntity, objName);
- Property newProperty = new Property();
- newProperty.setName(objName);
- newProperty.setValue(value);
+ Property newProperty = ldapStore.getProperty(thisEntity, objName);
newObj = newProperty;
} catch (ObjectNotFoundException ex) {
throw new ClusterStorageException("Property "+objName+" not found in "+sysKey);
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index b37cc8a..51b98b0 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -175,7 +175,7 @@ public class Bootstrap PropertyDescription pd = pdList.list.get(i);
String propName = pd.getName();
String propVal = propName.equals("Name")?itemName:pd.getDefaultValue();
- props.list.add(new Property(propName, propVal));
+ props.list.add(new Property(propName, propVal, pd.getIsMutable()));
}
CompositeActivity ca = new CompositeActivity();
@@ -259,8 +259,8 @@ public class Bootstrap // assign admin role
Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'");
rolePath.addAgent(agentPath);
- Gateway.getStorage().put(agentPath.getSysKey(), new Property("Name", name), null);
- Gateway.getStorage().put(agentPath.getSysKey(), new Property("Type", "Agent"), null);
+ Gateway.getStorage().put(agentPath.getSysKey(), new Property("Name", name, true), null);
+ Gateway.getStorage().put(agentPath.getSysKey(), new Property("Type", "Agent", false), null);
Logger.msg("Bootstrap.checkAgent() - Done");
} catch (Exception ex) {
Logger.error("Unable to create "+name+" user.");
@@ -298,14 +298,14 @@ public class Bootstrap thisServerPath.setEntity(serverEntity);
Gateway.getLDAPLookup().add(thisServerPath);
}
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Name", serverName), null);
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Type", "Server"), null);
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("KernelVersion", Resource.getKernelVersion()), null);
+ Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Name", serverName, false), null);
+ Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Type", "Server", false), null);
+ Gateway.getStorage().put(serverEntity.getSysKey(), new Property("KernelVersion", Resource.getKernelVersion(), true), null);
if (Gateway.getProperty("ItemServer.Proxy.port") != null)
Gateway.getStorage().put(serverEntity.getSysKey(),
- new Property("ProxyPort", Gateway.getProperty("ItemServer.Proxy.port")), null);
+ new Property("ProxyPort", Gateway.getProperty("ItemServer.Proxy.port"), true), null);
Gateway.getStorage().put(serverEntity.getSysKey(),
- new Property("ConsolePort", String.valueOf(Logger.getConsolePort())), null);
+ new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
Gateway.getProxyManager().connectToProxyServer(Gateway.getProperty("ItemServer.name"), Integer.parseInt(Gateway.getProperty("ItemServer.Proxy.port")));
}
diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index d0a017c..58cf503 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -53,10 +53,10 @@ public class Module { public void addModuleItem(String moduleXML) {
NewItem moduleItem = new NewItem(name, "/desc/modules/", "ModuleWorkflow");
// Module properties
- moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns));
- moduleItem.properties.add(new com.c2kernel.property.Property("Name", name));
- moduleItem.properties.add(new com.c2kernel.property.Property("Type", "Module"));
- moduleItem.properties.add(new com.c2kernel.property.Property("Version", info.version));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns, false));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Name", name, false));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Type", "Module", false));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Version", info.version, true));
// Add dependency for all children
Dependency children = new Dependency("Contents");
for (ModuleImport thisImport : imports.list) {
diff --git a/src/main/java/com/c2kernel/property/Property.java b/src/main/java/com/c2kernel/property/Property.java index 3022cc5..6b7c4ee 100644 --- a/src/main/java/com/c2kernel/property/Property.java +++ b/src/main/java/com/c2kernel/property/Property.java @@ -17,6 +17,7 @@ public class Property implements C2KLocalObject {
private String mName;
private String mValue;
+ private boolean mMutable = true;
/**************************************************************************
@@ -24,18 +25,17 @@ public class Property implements C2KLocalObject **************************************************************************/
public Property()
{
- setName( "" );
- setValue( "" );
}
/**************************************************************************
*
**************************************************************************/
- public Property( String name, String value )
+ public Property( String name, String value, boolean mutable )
{
setName( name );
setValue( value );
+ setMutable( mutable );
}
/**************************************************************************
@@ -48,7 +48,17 @@ public class Property implements C2KLocalObject }
- /**************************************************************************
+ public boolean isMutable() {
+ return mMutable;
+ }
+
+
+ public void setMutable(boolean mMutable) {
+ this.mMutable = mMutable;
+ }
+
+
+/**************************************************************************
*
**************************************************************************/
@Override
diff --git a/src/main/java/com/c2kernel/property/PropertyDescription.java b/src/main/java/com/c2kernel/property/PropertyDescription.java index cd3b93c..c0b6df6 100644 --- a/src/main/java/com/c2kernel/property/PropertyDescription.java +++ b/src/main/java/com/c2kernel/property/PropertyDescription.java @@ -71,7 +71,7 @@ public class PropertyDescription public Property getProperty()
{
- return new Property(mName,mDefaultValue);
+ return new Property(mName, mDefaultValue, mIsMutable);
}
}
diff --git a/src/main/java/com/c2kernel/property/PropertyDescriptionList.java b/src/main/java/com/c2kernel/property/PropertyDescriptionList.java index a6c68e2..ed93008 100644 --- a/src/main/java/com/c2kernel/property/PropertyDescriptionList.java +++ b/src/main/java/com/c2kernel/property/PropertyDescriptionList.java @@ -55,7 +55,8 @@ public class PropertyDescriptionList extends CastorArrayList<PropertyDescription PropertyDescription pd = list.get(i);
String propName = pd.getName();
String propVal = pd.getDefaultValue();
- props.list.add( new Property(propName, propVal));
+ boolean isMutable = pd.getIsMutable();
+ props.list.add( new Property(propName, propVal, isMutable));
}
return props;
}
diff --git a/src/main/resources/boot/OD/Item.xsd b/src/main/resources/boot/OD/Item.xsd index c46de43..22c4ace 100644 --- a/src/main/resources/boot/OD/Item.xsd +++ b/src/main/resources/boot/OD/Item.xsd @@ -89,6 +89,7 @@ <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="mutable" type="xs:boolean" default="true" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
diff --git a/src/main/resources/boot/OD/Module.xsd b/src/main/resources/boot/OD/Module.xsd index 98220fd..2b8fefd 100644 --- a/src/main/resources/boot/OD/Module.xsd +++ b/src/main/resources/boot/OD/Module.xsd @@ -220,6 +220,7 @@ <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="mutable" type="xs:boolean" default="true" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
diff --git a/src/main/resources/mapFiles/PropertiesMap.xml b/src/main/resources/mapFiles/PropertiesMap.xml index cdb27fc..b13d98d 100644 --- a/src/main/resources/mapFiles/PropertiesMap.xml +++ b/src/main/resources/mapFiles/PropertiesMap.xml @@ -5,6 +5,9 @@ <field name="mName" type="string" direct="false" get-method="getName" set-method="setName">
<bind-xml name="name" node="attribute"/>
</field>
+ <field name="mMutable" type="boolean" direct="false" get-method="isMutable" set-method="setMutable">
+ <bind-xml name="mutable" node="attribute"/>
+ </field>
<field name="mValue" type="string" direct="false" get-method="getValue" set-method="setValue">
<bind-xml node="text"/>
</field>
|
