Xml AdminApiSocket::execute( Xml req ) {
    ASSERTMSG( connected , "Not connected" );

    // get request ID
    String requestId = req.getAttribute( "requestId" , "" );
    if( requestId.isEmpty() )
        requestId = setXmlRequestId( req );
    String request = req.serialize();

    bool disconnected = false;
    protocol.writeMessage( socket , request , disconnected );
    if( disconnected )
        connected = false;
    ASSERTMSG( connected , "Connection is closed from server side while making request" );

    String response;
    if( !protocol.readMessage( socket , response , true , disconnected ) ) {
        if( disconnected )
            connected = false;
        ASSERTMSG( connected , "Connection is closed from server side while reading response" );
        ASSERTFAILED( "Timeout while waiting response for request=" + requestId );
        return( Xml() );
    }

    Xml xml = Xml::read( response , "xmlcallresult" );
    return( xml );
}
Exemple #2
0
void MindMap::createFromXml( Xml xml )
{
	// child elements are MindAreaInfo
	for( Xml xmlChild = xml.getFirstChild( "MindArea" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "MindArea" ) ) {
		// construct MindArea from attributes
		MindAreaInfo *info = new MindAreaInfo;
		mindAreas.add( info );

		info -> createFromXml( xmlChild );

		// get areaId
		String id = info -> getAreaId();
		ASSERTMSG( !id.isEmpty() , "area is not defined: " + xmlChild.serialize() );
		ASSERTMSG( mindAreaMap.get( id ) == NULL , id + ": area duplicate found for id=" + id );

		// add
		mindAreaMap.add( id , info );
	}

	// child elements are MindAreaInfo
	Xml xmlLinks = xml.getFirstChild( "MindLinks" );

	Xml xmlChild;
	if( xmlLinks.exists() )
		xmlChild = xmlLinks.getFirstChild( "MindLink" );
	for( ; xmlChild.exists(); xmlChild = xmlChild.getNextChild( "MindLink" ) ) {
		// construct MindArea from attributes
		MindLinkInfo *info = new MindLinkInfo;
		info -> createFromXml( xmlChild );
		mindLinks.add( info );
	}
}
void AdminApiSocket::send( Xml req ) {
    ASSERTMSG( connected , "Not connected" );

    // get request ID
    String requestId = req.getAttribute( "requestId" , "" );
    if( requestId.isEmpty() )
        requestId = setXmlRequestId( req );
    String request = req.serialize();

    bool disconnected = false;
    protocol.writeMessage( socket , request , disconnected );
    if( disconnected )
        connected = false;
    ASSERTMSG( connected , "Connection is closed from server side while making request" );
}
void MindRegionTypeDef::createConnectorSetFromXml( Xml xml ) {
	if( !xml.exists() )
		return;

	for( Xml xmlChild = xml.getFirstChild( "connector" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "connector" ) ) {
		// construct MindArea from attributes
		MindRegionConnectorDef *connector = new MindRegionConnectorDef;
		connector -> createFromXml( xmlChild );

		String id = connector -> getId();
		ASSERTMSG( !id.isEmpty() , "region type connector is not well-defined: " + xmlChild.serialize() );

		// add to set and map
		connectorSet.add( connector );
		connectorMap.add( id , connector );
	}
}
void MindMap::createRegionTypeDefSet( Xml xml ) {
	if( !xml.exists() )
		return;

	for( Xml xmlChild = xml.getFirstChild( "region-type" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "region-type" ) ) {
		// construct MindRegionType from attributes
		MindRegionTypeDef *info = new MindRegionTypeDef;
		regionTypeSet.add( info );

		info -> createFromXml( xmlChild );

		// get region type name
		String name = info -> getName();
		ASSERTMSG( !name.isEmpty() , "region type is not defined: " + xmlChild.serialize() );
		ASSERTMSG( regionTypeMap.get( name ) == NULL , name + ": region type duplicate found for name=" + name );

		// add
		regionTypeMap.add( name , info );
	}
}
void MindMap::createAreaDefSet( Xml xml ) {
	if( !xml.exists() )
		return;

	for( Xml xmlChild = xml.getFirstChild( "area" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "area" ) ) {
		// construct MindArea from attributes
		MindAreaDef *info = new MindAreaDef;
		mindAreaSet.add( info );

		info -> createFromXml( xmlChild );

		// get areaId
		String id = info -> getAreaId();
		ASSERTMSG( !id.isEmpty() , "area is not defined: " + xmlChild.serialize() );
		ASSERTMSG( mindAreaMap.get( id ) == NULL , id + ": area duplicate found for id=" + id );

		// add
		mindAreaMap.add( id , info );

		// add regions to map
		createRegionMap( info );
	}
}