Ila

org.topoweb.ila.protocol
Class RemoteService

java.lang.Object
  |
  +--org.topoweb.ila.protocol.RemoteService
All Implemented Interfaces:
ProtocolConstants
Direct Known Subclasses:
RemoteIla, RemoteMirror, RemoteRegistrar

public abstract class RemoteService
extends java.lang.Object
implements ProtocolConstants

Base class for the client-side of our XML/DOM protocol.

Author:
Babak Farhang

Field Summary
 
Fields inherited from interface org.topoweb.ila.protocol.ProtocolConstants
PC_BACKLINK_COUNT, PC_BACKLINKS, PC_CO_BACKLINK_COUNT, PC_CO_FORELINK_COUNT, PC_CONTENT_LENGTH, PC_CONTENT_TYPE, PC_ERROR_CODE, PC_EXPIRATION, PC_FAIL, PC_FIRST, PC_FORELINK_COUNT, PC_FORELINKS, PC_GET_KNOWN, PC_GET_LINK_NODE, PC_GET_LINKS, PC_GET_NODE, PC_HI, PC_HTTP, PC_ID, PC_ILA, PC_INCOMMUNICADO, PC_LAST, PC_LAST_MODIFIED, PC_LINK_NODE, PC_LINK_TYPE, PC_LO, PC_MAX_COUNT, PC_NODE, PC_NODE_SET, PC_OKAY, PC_ORI, PC_PAGE, PC_REGISTER, PC_REQUEST, PC_RESPONSE, PC_SIZE, PC_STATE, PC_STATUS, PC_SYNC_VERSION_ID, PC_SYNC_VERSION_TIMESTAMP, PC_TITLE, PC_USER, PC_USER_AGENT, PC_USER_NAMESPACE, PC_VERSION, PC_VERSION_ID, PC_VERSION_TIMESTAMP
 
Constructor Summary
RemoteService()
           
 
Method Summary
protected  void checkVersion(org.w3c.dom.Element env)
          Checks the version of the response.
protected  org.w3c.dom.Element getAnswerElement(org.w3c.dom.Element env, java.lang.String id, java.lang.String answerTag)
          Extracts the answser from the response envelop.
 java.lang.String getVersion()
          Returns the version string of the protocol implemented.
 java.lang.String newTransactionId()
          Returns a new transaction ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteService

public RemoteService()
Method Detail

getVersion

public java.lang.String getVersion()
Returns the version string of the protocol implemented.


newTransactionId

public java.lang.String newTransactionId()
Returns a new transaction ID. Each invocation is supposed to return a new value that is unique over the life of the instance.

Implementation Note

This method is not strictly-speaking thread-safe: it is possible (though exceedingly unlikely) that the value returned will not be unique.

Returns:
a new transaction ID

checkVersion

protected void checkVersion(org.w3c.dom.Element env)
                     throws IlaException
Checks the version of the response. The base implementation does nothing.

Parameters:
env - the envelop (root) element of the response
Throws:
IlaException - if this class cannot interpret the version of the protocol spoken by the server

getAnswerElement

protected final org.w3c.dom.Element getAnswerElement(org.w3c.dom.Element env,
                                                     java.lang.String id,
                                                     java.lang.String answerTag)
                                              throws IlaException
Extracts the answser from the response envelop.

Parameters:
env - the root element of the response (<ila>)
id - the expected transaction ID
answerTag - the name of the element containing the response
Returns:
the "answer" element, or null, if answerTag was null
Throws:
IlaException - if the response status is not "OKAY"

Ila

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.