Class AbstractStructureProvider<C,​S extends Structure>

  • Type Parameters:
    C - the connection identifying how to retrieve the structure view.
    S - the provided structure.
    All Implemented Interfaces:
    StructureProvider, Disposable

    public abstract class AbstractStructureProvider<C,​S extends Structure>
    extends Object
    implements StructureProvider, Disposable
    Defines a base implementation of structure provider. This class provides facilities to load a structure given some connection parameters. The retrieved structure is kept in cache for two minutes, time after which the structure is disposed and recomputed on-demand if requested again.

    Clients may subclass this class.

    • Constructor Detail

      • AbstractStructureProvider

        protected AbstractStructureProvider()
        Instantiates a new structure provider.
    • Method Detail

      • dispose

        public void dispose()
        Disposes temporary resources allocated when reading the structure.
        Specified by:
        dispose in interface Disposable
      • getStructure

        protected S getStructure​(PropertySet properties,
                                 boolean forceRefresh)
                          throws CoreException
        Retrieve the structure for the specified connection parameters.

        Subclass is not required to override and shall use the base implementation as-is.

        Parameters:
        properties - options configuring the retrieval of the structure. Those options are provided by the servlet request through headers or query parameters.
        forceRefresh - if true the structure is forced to recompute. If false, the structure is computed only if not present in the cache (as read by a previous request).
        Returns:
        the structure matching the connection parameters.
        Throws:
        CoreException - if anything prevents from connecting to the data source and to read the structure.
      • getConnectionID

        protected abstract C getConnectionID​(PropertySet properties)
                                      throws CoreException
        Identifies the connection parameters necessary to connect to the data source and to compute the structure.

        The class hosting the connection parameters is required to override the hashCode() and equals() methods, so that two instances constructed with the same properties are considered equal and so the structure can be cached efficiently.

        Parameters:
        properties - options configuring the retrieval of the structure. Those options are provided by the servlet request through headers or query parameters.
        Returns:
        the connection parameters necessary to connect to the data source.
        Throws:
        CoreException - if anything prevents from computing the connection parameters.
      • verifyHeader

        protected String verifyHeader​(PropertySet properties,
                                      String name)
                               throws CoreException
        Retrieves the value of the specified header name or query parameter in the servlet request.
        Parameters:
        properties - options configuring the retrieval of the structure. Those options are provided by the servlet request through headers or query parameters.
        name - the name of the property to look for.
        Returns:
        the value matching the specified property name
        Throws:
        CoreException - if the property is not defined.
      • verifyPasswordHeader

        protected String verifyPasswordHeader​(PropertySet properties,
                                              String name)
                                       throws CoreException
        Retrieves the password value of the specified header name or query parameter in the servlet request,

        If a value matching the specified property name is found, it is decrypted using the EncryptionProvider class, provided the "encryptionAlgorithm" and "encryptionIV" properties are also set.

        Parameters:
        properties - options configuring the retrieval of the structure. Those options are provided by the servlet request through headers or query parameters.
        name - the name of the property to look for.
        Returns:
        the password value matching the specified property name
        Throws:
        CoreException - if the property is not defined.
        See Also:
        EncryptionProvider
      • verifySystemProperty

        protected String verifySystemProperty​(String name)
                                       throws CoreException
        Retrieves the value of the specified System property name or servlet context parameter.
        Parameters:
        name - the name of the property to look for.
        Returns:
        the value matching the specified property name
        Throws:
        CoreException - if the property is not defined.
      • loadStructure

        protected abstract S loadStructure​(PropertySet properties,
                                           C connection)
                                    throws CoreException
        Connects to the data source using the specified connection parameters and loads the structure.
        Parameters:
        properties - options configuring the retrieval of the structure. Those options are provided by the servlet request through headers or query parameters.
        connection - the connection parameters necessary to connect to the data source, as returned by the getConnectionID() method.
        Returns:
        the structure read using the specified connection parameters.
        Throws:
        CoreException - if anything prevents from connecting to the data source and to read the structure.
        See Also:
        getConnectionID(PropertySet)
      • getRoots

        public List<Node> getRoots​(PropertySet properties)
                            throws CoreException
        Returns the list of root nodes of the structure.

        Subclass is not required to override and shall use the base implementation as-is.

        Specified by:
        getRoots in interface StructureProvider
        Parameters:
        properties - options configuring the retrieval of the root nodes. Those options are provided by the servlet request through headers or query parameters.
        Returns:
        the root nodes of the structure.
        Throws:
        CoreException - if anything prevents from retrieving the nodes.
      • getChildren

        public List<Node> getChildren​(PropertySet properties,
                                      String parentId)
                               throws CoreException
        Returns the list of child nodes of the specified parent.

        Subclass is not required to override and shall use the base implementation as-is.

        Specified by:
        getChildren in interface StructureProvider
        Parameters:
        properties - options configuring the retrieval of the children nodes. Those options are provided by the servlet request through headers or query parameters.
        parentId - the identifier of the parent node.
        Returns:
        the child nodes of the specified parent.
        Throws:
        CoreException - if anything prevents from retrieving the nodes.
        See Also:
        Node.getId()