Ila

org.topoweb.ila.server.spi
Class IlaImpl

java.lang.Object
  |
  +--org.topoweb.ila.server.spi.IlaImpl
All Implemented Interfaces:
Ila, LocalIla, NodeConstants, StateConstants

public class IlaImpl
extends java.lang.Object
implements LocalIla, StateConstants

Base local Ila implementation class. This is just a thin wrapper around a DataAccessor instance. The methods in this class throw the following more specific IlaExceptions:

Author:
Babak Farhang
See Also:
DataAccessor

Field Summary
 
Fields inherited from interface org.topoweb.ila.NodeConstants
BACK, FIRST_PAGE, FORE, LAST_PAGE, LINK_MASK, PAGE_MASK
 
Fields inherited from interface org.topoweb.ila.StateConstants
NF, NK, NV, OK
 
Constructor Summary
IlaImpl(DataAccessor db, ServiceProviderResolver resolver)
          Creates a new instance with the given DataAccessor.
 
Method Summary
 NodeSet getKnown(org.topoweb.util.StringRange range, int pageOrder, int maxCount)
          Returns a list of nodes known by Ila in the given lexical range as a NodeSet.
 LinkNode getLinkNode(org.topoweb.net.Ori src, int linkType, org.topoweb.util.StringRange linkRange, int pageOrder, int maxCount)
          Returns a linked-node containing links with the specified type and in the specified lexical range.
 NodeSet getLinks(org.topoweb.net.Ori src, int linkType, org.topoweb.util.StringRange linkRange, int pageOrder, int maxCount)
          Returns the links of the specified type for the node with the given Ori as a NodeSet.
 Node getNode(org.topoweb.net.Ori ori)
          Returns the node for the specified Ori.
 LinkNode register(org.topoweb.net.Ori ori)
          This base implementation just returns a node in the NK state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlaImpl

public IlaImpl(DataAccessor db,
               ServiceProviderResolver resolver)
Creates a new instance with the given DataAccessor. The resolver is used to ensure that the instance is the authority server for any given src ORI.

Parameters:
db - the data accessor implementation class
resolver - the service resolver (used to do sanity checks on the arguments)
Method Detail

getNode

public Node getNode(org.topoweb.net.Ori ori)
             throws ResolutionException,
                    DataAccessorException,
                    IlaException
Description copied from interface: Ila
Returns the node for the specified Ori. The returned node encapsulates Ila's state of knowledge about the resource represented by the given ORI. That is, getNode(src, ..).getOri().equals(src) must evaluate to true.

Specified by:
getNode in interface Ila
Parameters:
ori - the ORI of the resource
Returns:
the node representing the resource as known by Ila. Never null.
Throws:
ResolutionException - if this server is not the authority on the ori
DataAccessorException - if the underlying data accessor throws it
IlaException - if an error occurs

getLinks

public NodeSet getLinks(org.topoweb.net.Ori src,
                        int linkType,
                        org.topoweb.util.StringRange linkRange,
                        int pageOrder,
                        int maxCount)
                 throws ResolutionException,
                        DataAccessorException,
                        IlaException
Description copied from interface: Ila
Returns the links of the specified type for the node with the given Ori as a NodeSet.

The type of links returned, forelinks or backlinks, is determined by bitwise ORing the linkType parameter with NodeConstants mask.

The lexical range of the links to be returned is determined by the linkRange parameter.

Some nodes can have very many links, and it may be infeasible for an Ila server to return all the links that match a given request. In such an event the returned links will either start from the linkRange's lower bound if (pageOrder & PAGE_MASK ) == FIRST_PAGE, or end at its upper bound, otherwise. The user can detect whether the returned links were truncated by examining the returned NodeSet.

Note

The state information of the returned links is seldom authoritative. In fact, if the links are of the forward type (FORE) and they were just added, then it is likely they will be returned in the NK state. For any given linked node, authoritative state information is retrieved using the getNode method.

Specified by:
getLinks in interface Ila
Parameters:
src - the Ori of the return linked-node
linkType - specifies whether the returned node set contains forelinks or backlinks
linkRange - the lexical range of the links returned
pageOrder - specifies whether if truncated, the links should begin from the first page or end on the last page of the link result set
maxCount - the maximum number of links that may be returned; a value <= 0 indicates an unlimited number
Returns:
a node set encapsulating the Ila server's response
Throws:
ResolutionException - if this server is not the authority on the src ORI
DataAccessorException - if the underlying data accessor throws it
IlaException - if an error occurs
See Also:
NodeConstants, NodeConstants.FIRST_PAGE, NodeConstants.LAST_PAGE

getLinkNode

public LinkNode getLinkNode(org.topoweb.net.Ori src,
                            int linkType,
                            org.topoweb.util.StringRange linkRange,
                            int pageOrder,
                            int maxCount)
                     throws ResolutionException,
                            DataAccessorException,
                            IlaException
Description copied from interface: Ila
Returns a linked-node containing links with the specified type and in the specified lexical range. The returned node represents Ila's state of knowledge about the resource represented by the given ORI src. That is, the expression
getLinkNode(src, ..).getOri().equals(src)
must evaluate to true.

This method is equivalent to invoking getNode followed by getLinks. That is, for example,

new LinkNode(src, getNode(src).getState(), null, getLinks(src, BACK, StringRange.ALL, FIRST_PAGE, 0) );
Example usage:
      Ila ila = .. ;
      LinkNode node
      = ila.getLinkNode(
      srcOri, NodeConstants.BACK, StringRange.ALL, FIRST_PAGE, 100);
      ..
 

The goal here is not a convenience method. Rather, we expect if implemented over the wire, the returned LinkNode will be marshalled in one pass, not two.

Specified by:
getLinkNode in interface Ila
Parameters:
src - the ORI of the return linked-node
linkType - specifies whether the returned linked-node contains forelinks or backlinks
linkRange - the lexical range of the links returned
pageOrder - specifies whether if truncated, the links should begin from the first page or end
maxCount - the maximum number of links that may be returned; a value <= 0 indicates an unlimited number
Returns:
a linked-node encapsulating the Ila server's response
Throws:
ResolutionException - if this server is not the authority on the src ORI
DataAccessorException - if the underlying data accessor throws it
IlaException - if an error occurs
See Also:
NodeConstants, NodeConstants.FIRST_PAGE, NodeConstants.LAST_PAGE

getKnown

public NodeSet getKnown(org.topoweb.util.StringRange range,
                        int pageOrder,
                        int maxCount)
                 throws DataAccessorException
Description copied from interface: Ila
Returns a list of nodes known by Ila in the given lexical range as a NodeSet.

Specified by:
getKnown in interface Ila
Parameters:
range - the lexical range of the ORIs of the nodes to be returned
pageOrder - the page order
maxCount - the maximum number of links that may be returned; a value <= 0 indicates an unlimited number
Returns:
a perhaps truncated list of nodes
Throws:
DataAccessorException - if the underlying data accessor throws it
See Also:
NodeConstants.FIRST_PAGE, NodeConstants.LAST_PAGE

register

public LinkNode register(org.topoweb.net.Ori ori)
                  throws ResolutionException,
                         IlaException
This base implementation just returns a node in the NK state. It does not even log the invocation.

Specified by:
register in interface Ila
Parameters:
ori - the ORI of the resource
Returns:
a link-node containing the forward links of the resource
Throws:
ResolutionException - if this server is not the authority on the ori
IlaException - if an error occurs

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.