Below is my transaction update code with xml.
public boolean updateAnnexOption(String pSection, String pOption, String pValue)
{
Document confObject = null ;
String xml = null ;
boolean retval = true ;
logger.info("Starts...." + pSection + "," + pOption + "," + pValue) ;
try {
xml = "<ConfData>" +
"<CfgDeltaTransaction>" +
"<CfgTransaction>" +
"<DBID value='" + mTransactionDBID + "'/>" +
"</CfgTransaction>" +
"<changedUserProperties>" +
"<list_pair key='" + pSection + "'>" +
"<str_pair key='" + pOption + "' value='" + pValue +"'/>" +
"</list_pair>" +
"</changedUserProperties>" +
"</CfgDeltaTransaction>" +
"</ConfData>";
logger.info("Update annex option...." + xml) ;
confObject = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))) ;
retval = updateObjects(CfgObjectType.CFGTransaction , confObject, null ) ;
} catch (Exception ex) {
logger.warning(CtiLogger.logstr("Exception....",ex)) ;
retval = false ;
}
return retval ;
}
boolean updateObjects(GEnum pObjectType, Document pConfObject, KeyValueCollection pFilter)
{
RequestUpdateObject message ; // Configuration Server에 변경을 요청 객체
Message response ; // Configuration Server에 변경을 결과 응답 메시지
boolean retval = true ;
//TreeMap retMap = new TreeMap() ; // Return 값 저장 변수
logger.info("Starts...." + pObjectType + "," + pConfObject + "," + pFilter) ;
try
{
// Configuration Server가 연결이 될 때까지 기다린다.
if( mConfServerProtocol.getState().equals(ChannelState.Opened))
{
// request message를 만든다
message = RequestUpdateObject.create(new Integer(pObjectType.ordinal()), pConfObject , pFilter);
logger.info("RequestUpdateObject....\n"+message) ;
// 정보 조회를 요청한다
response = mConfServerProtocol.request(message) ;
// 결과값이 왔는지 확인한다
if( response == null || !(response instanceof EventObjectUpdated) )
{
// 결과값이 없거나 object를 읽었다는 Event가 아니면
if( response == null )
{
logger.info("RequestUpdateObject response - no object updated....") ;
} else
{
logger.info("RequestUpdateObject response - no object updated....\n" + decode(response.toString()) ) ;
switch(response.messageId())
{
case EventError.ID :
EventError eventError = (EventError)response ;
if ( eventError.getErrorCode() == 29 )
{
mReadOnlyMode = true ;
logger.warning("Configuration server working mode is changed to Read-Only Mode....") ;
}
break ;
default:
break ;
}
}
retval = false ;
} else
{
retval = true ;
logger.info("RequestReadObjects response - object updated....\n" + decode(response.toString()) ) ;
}
} else
{
retval = false ;
logger.info("RequestUpdateObject response - no object updated because cfg server is not connected....") ;
}
} catch (Exception ex)
{
logger.warning(CtiLogger.logstr("Exception....",ex)) ;
retval = false ;
}
return retval;
}