com.ibm.portal.resolver.friendly.service
Interface FriendlySelectionService

All Superinterfaces:
Disposable
All Known Subinterfaces:
PortalFriendlySelectionService, PortletFriendlySelectionService

public interface FriendlySelectionService
extends Disposable

Service that helps to work with friendly selection. The service allows to encode and decode friendly selection prefixes to and from portal pages. In addition it is possible to generate URLs in a special friendly URL format.

Note that this interface extends Disposable, it needs to be disposed explicitly before leaving scope by calls to Disposable.dispose()

Since:
6.1.0

Nested Class Summary
static interface FriendlySelectionService.PathMatchingResult
          The result of a path matching operation.
 
Method Summary
 SearchableTreeModel<NavigationNode> getSearchableTreeModel()
           Returns the SearchableTreeModel used to encode and decode friendly selections.
 FriendlyURLFactory getURLFactory()
          Returns access to the URL generation functionality for friendly URLs.
 FriendlySelectionService.PathMatchingResult matchPathPrefix(java.lang.String friendlyPath, Identifiable node)
           Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node as a prefix.
 FriendlySelectionService.PathMatchingResult matchPathPrefix(java.lang.String friendlyPath, java.lang.String pathInfo)
           Checks if the friendly path that is passed in as a parameter has the given path info as a prefix.
 boolean pathEquals(java.lang.String friendlyPath, Identifiable node)
           Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node.
 boolean pathPrefixMatches(java.lang.String friendlyPath, Identifiable node)
           Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node as a prefix.
 boolean resolve(SelectionResult res, java.lang.String path)
          Convenience method that converts the complete path string into a SelectionResult.
 boolean resolve(SelectionResult res, java.lang.String path, int off, int len)
           Converts from a path to a list of ObjectID of selections
 boolean write(java.io.Writer out, NavigationNode node)
           Encodes the friendly selection string from a node.
 
Methods inherited from interface com.ibm.portal.Disposable
dispose
 

Method Detail

getSearchableTreeModel

SearchableTreeModel<NavigationNode> getSearchableTreeModel()

Returns the SearchableTreeModel used to encode and decode friendly selections. The model will typically be based on the navigation model for the current user but might differ from it if nodes in the navigation model are hidden from the friendly name hierarchy.

Returns:
the tree model, not null

getURLFactory

FriendlyURLFactory getURLFactory()
Returns access to the URL generation functionality for friendly URLs. The FriendlyURLFactory is part of the instance of the service and does not need to be disposed separately.

Returns:
factory to create friendly URLs, not null

resolve

boolean resolve(SelectionResult res,
                java.lang.String path)
                throws ModelException
Convenience method that converts the complete path string into a SelectionResult. See #resolve(SelectionResult, String, int, int, SearchableTreeModel, Object) for more details.

The friendly path corresponds to the string generated by the write(Writer, NavigationNode) method, i.e. it must contain a correctly escaped URL prefix.

Throws:
ModelException

resolve

boolean resolve(SelectionResult res,
                java.lang.String path,
                int off,
                int len)
                throws ModelException

Converts from a path to a list of ObjectID of selections

.

The friendly path corresponds to the string generated by the write(Writer, NavigationNode) method, i.e. it must contain a correctly escaped URL prefix.

Parameters:
res - bean that contains the resulting list of selections
path - path string to decode
off - first valid character in the path string, should point to the starting slash
len - length of the valid segment
Returns:
true, if the complete path could be matched, else false
Throws:
ModelException - - if the path could not be resolved

write

boolean write(java.io.Writer out,
              NavigationNode node)
              throws java.io.IOException,
                     ModelException

Encodes the friendly selection string from a node. The node must be part of the TreeModel returned by getSearchableTreeModel(). In case the friendly name cannot be generated the method returns false and no output is written to the writer.

The generated friendly path will be URL escaped, i.e. characters that are not valid for the URL are replaced by their UTF8 based % escapes.

Parameters:
out - target writer to write the friendly string to
node - node to encode, not null
Returns:
true if the node has a friendly name, else false.
Throws:
java.io.IOException - - if the friendly name could not be generated
ModelException - - if the model could not be accessed

pathEquals

boolean pathEquals(java.lang.String friendlyPath,
                   Identifiable node)
                   throws java.io.IOException,
                          ModelException

Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node. If the friendlyPath is null or the empty string and the node is not represented by a friendly path, then this method returns true.

The friendly path starts with a slash, e.g. /test/page

The friendly path corresponds to the string generated by the write(Writer, NavigationNode) method, i.e. it must contain a correctly escaped URL prefix.

Parameters:
friendlyPath - path to check, may be null
node - the identifiable to check for. This node does not necessarily need to be part of the model. Must not be null
Returns:
true if the path matches, else false
Throws:
java.io.IOException
ModelException

pathPrefixMatches

boolean pathPrefixMatches(java.lang.String friendlyPath,
                          Identifiable node)
                          throws java.io.IOException,
                                 ModelException

Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node as a prefix. If the friendlyPath is null or the empty string and the node is not represented by a friendly path, then this method returns true.

The friendly path starts with a slash, e.g. /test/page

The friendly path corresponds to the string generated by the write(Writer, NavigationNode) method, i.e. it must contain a correctly escaped URL prefix.

Parameters:
friendlyPath - path to check, may be null
node - the identifiable to check for. This node does not necessarily need to be part of the model. Must not be null
Returns:
true if the path matches, else false
Throws:
java.io.IOException
ModelException
Since:
6.1.0.3

matchPathPrefix

FriendlySelectionService.PathMatchingResult matchPathPrefix(java.lang.String friendlyPath,
                                                            Identifiable node)
                                                            throws java.io.IOException,
                                                                   ModelException

Checks if the friendly path that is passed in as a parameter matches the friendly path that corresponds to the node as a prefix. If the friendlyPath is null or the empty string and the node is not represented by a friendly path, then the path is considered to match.

The friendly path starts with a slash, e.g. /test/page

The friendly path corresponds to the string generated by the write(Writer, NavigationNode) method, i.e. it must contain a correctly escaped URL prefix.

Parameters:
friendlyPath - path to check, may be null
node - the identifiable to check for. This node does not necessarily need to be part of the model. Must not be null
Returns:
a PathMatchingResult. The PathMatchingResult contains a flag indicating if the path prefix matches, and a string that represents the not matching suffix of the path, if one exists.
Throws:
java.io.IOException
ModelException
Since:
7.0.0.0

matchPathPrefix

FriendlySelectionService.PathMatchingResult matchPathPrefix(java.lang.String friendlyPath,
                                                            java.lang.String pathInfo)
                                                            throws java.io.IOException

Checks if the friendly path that is passed in as a parameter has the given path info as a prefix.

The friendly path and path info starts with a slash, e.g. /test/content

Parameters:
friendlyPath - path to check
pathInfo - path info string the path should be matched against
Returns:
a PathMatchingResult. The PathMatchingResult contains a flag indicating if the path prefix matches, and a string that represents the not matching suffix of the path, if one exists.
Throws:
java.io.IOException
ModelException
Since:
7.0.0.0