|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.configuration.protocol.obj.ConfObjectBase
com.genesyslab.platform.configuration.protocol.obj.ConfObject
public class ConfObject
Class represents particular configuration object information container.
It contains a compact set of properties which are indexed and mapped in accordance to referred actual
configuration server CfgMetadata
.
RequestReadObjects readReq = RequestReadObjects.create();
readReq.setObjectType(cfgObjectType.ordinal());
Message resp = protocol.request(readReq);
if (resp instanceof EventObjectsRead) {
ConfObjectsCollection objects = ((EventObjectsRead) resp).getObjects();
if (objects != null) {
for (ConfObject obj : objects) {
System.out.println("Got " + obj.getObjectType() + " object \""
+ obj.getPropertyValue("name")
+ "\", dbid = " + obj.getObjectDbid());
}
}
}
CfgMetadata metadata = protocol.getServerContext().getMetadata();
ConfObject obj0 = new ConfObject(metadata, CfgObjectType.CFGHost);
obj0.setPropertyValue("name", "new-host-name");
obj0.setPropertyValue("IPaddress", "19.19.19.19");
obj0.setPropertyValue("type", 1);
obj0.setPropertyValue("state", 1);
obj0.setPropertyValue("LCAPort", "4999");
ConfStructure osInfo = (ConfStructure) obj0.getOrCreatePropertyValue("OSinfo");
osInfo.setPropertyValue("OStype", 8);
osInfo.setPropertyValue("OSversion", "7");
RequestCreateObject reqCreate = RequestCreateObject.create();
reqCreate.setObject(obj0);
Message resp = protocol.request(reqCreate);
if (resp instanceof EventObjectCreated) {
// Here is a configuration object returned by the configuration server after creation
// with assigned DBID and filled default values for unassigned properties:
ConfObject objCreated = ((EventObjectCreated) resp).getObject();
} else if (resp instanceof EventError) {
log.error("Error on object create: "
+ CfgUtilities.getErrorCode(((EventError) resp).getErrorCode())
+ "\tDescription: " + ((EventError) resp).getDescription());
}
ConfObjectDelta hostDelta = new ConfObjectDelta(metadata, CfgObjectType.CFGHost);
ConfObject obj = (ConfObject) hostDelta.getOrCreatePropertyValue("deltaHost");
obj.setPropertyValue("DBID", objDbid); // - required
obj.setPropertyValue("name", "new-host-name"); // - to rename the host object (if needed)
obj.setPropertyValue("IPaddress", "21.21.21.21"); // - to change address (if needed)
RequestUpdateObject reqUpdate = RequestUpdateObject.create();
reqUpdate.setObjectDelta(hostDelta);
Message resp = protocol.request(reqUpdate);
if (resp instanceof EventObjectUpdated) {
// The object has been updated
} else if (resp instanceof EventError) {
log.error("Error on object update: "
+ CfgUtilities.getErrorCode(((EventError) resp).getErrorCode())
+ "\tDescription: " + ((EventError) resp).getDescription());
}
ConfStructure
instance separately,
and set it as objects' property value like this (its not right, don't use it):
ConfStructure ownerId = new ConfStructure(metadata, CfgStructureType.CFGID);
ownerId.setPropertyValue("type", 7);
ownerId.setPropertyValue("DBID", 1);
folder.setPropertyValue("ownerID", ownerId);
It may work in some cases, but it can fail in other scenarios like XML serialization.getOrCreatePropertyValue()
:
ConfStructure ownerId = (ConfStructure) folder.getOrCreatePropertyValue("ownerID");
ownerId.setPropertyValue("type", 7);
ownerId.setPropertyValue("DBID", 1);
This method works for child structure or structure collection properties. For example,
adding of members to access group may look like:
ConfStructureCollection members = (ConfStructureCollection) accGroup.getOrCreatePropertyValue("memberIDs");
ConfStructure id = members.createStructure();
id.setPropertyValue("type", CfgObjectType.CFGPerson.ordinal());
id.setPropertyValue("DBID", person1.getObjectDbid());
members.add(id);
id = members.createStructure();
id.setPropertyValue("type", CfgObjectType.CFGPerson.ordinal());
id.setPropertyValue("DBID", person2.getObjectDbid());
members.add(id);
Note*: Structure collections does not control uniqueness of child elements.
So, in mentioned sample it is supposed that the persons are not present in the members list already.
Constructor Summary | |
---|---|
ConfObject(CfgDescriptionObject metadata)
Constructor for creation of uninitialized object of particular type. |
|
ConfObject(CfgMetadata metadata,
CfgObjectType objType)
Constructor for creation of uninitialized object of particular type. |
Method Summary | |
---|---|
CfgDescriptionObject |
getClassInfo()
Returns reference to the object class MetaData description. |
java.lang.Integer |
getObjectDbid()
Configuration objects DBID uniquely identifies configuration object of a particular type on particular configuration server. |
CfgObjectType |
getObjectType()
Returns type of the configuration object. |
Methods inherited from class com.genesyslab.platform.configuration.protocol.obj.ConfObjectBase |
---|
checkTypeCompatibility, clone, createChildElement, equals, getAttributeInfo, getOrCreatePropertyValue, getPropertyInfo, getPropertyValue, getPropertyValue, hashCode, setPropertyValue, setPropertyValue, toString, toString, toStringContentHelper, toStringHelper |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConfObject(CfgDescriptionObject metadata)
metadata
- configuration object class MetaData.
ConfObjectAttributeException
- if given MetaData is null or there is some problem
with its usage here.public ConfObject(CfgMetadata metadata, CfgObjectType objType)
metadata
- actual configuration server MetaData.objType
- configuration object type.
java.lang.NullPointerException
- if given MetaData is null.
ConfObjectAttributeException
- if there is no MetaData for referred type or
there is some problem with its usage here.Method Detail |
---|
public CfgDescriptionObject getClassInfo()
getClassInfo
in class ConfObjectBase
public CfgObjectType getObjectType()
public java.lang.Integer getObjectDbid()
[object type, object DBID]
uniquely specifies
particular configuration object in configuration server database.
This value is been assigned by configuration server at moment of the object creation
and can't be changed during its whole life cycle.
This method is a helper to find the DBID value in the object properties or
properties of child structures depending on this object type.
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |