Class TreeCache


  • @Technical
    @Bean
    @Singleton
    public class TreeCache
    extends Object
    A cache with the organizational tree of the application instances in Silverpeas. The tree is made up of spaces that can contain other spaces or applications and of component instances (aka applications).
    • Constructor Detail

      • TreeCache

        protected TreeCache()
    • Method Detail

      • clearCache

        public void clearCache()
        Clears the cache.
      • getSpaceInstLight

        public Optional<SpaceInstLight> getSpaceInstLight​(int spaceId)
        Gets the space instance with the specified identifier.
        Parameters:
        spaceId - the unique identifier of a space in Silverpeas.
        Returns:
        a SpaceInstLight object.
      • addSpace

        public Space addSpace​(Integer spaceId,
                              Space space)
        Adds the specified space in the cache if there is no yet a space cached with the given identifier.
        Parameters:
        spaceId - the unique identifier of a space.
        space - the space to add in the cache.
        Returns:
        either the added space or the already cached space.
      • removeSpace

        public void removeSpace​(int spaceId)
        Removes from the cache the space with the specified identifier.
        Parameters:
        spaceId - the unique identifier of a space.
      • setSubspaces

        public void setSubspaces​(int spaceId,
                                 List<SpaceInstLight> subspaces)
        Set the specified subspaces as children to the space with the given identifier. If there is no such space with the given identifier, then nothing is done. If the space has already some children, then they are all replaced by the specified ones.
        Parameters:
        spaceId - the unique identifier of a father space.
        subspaces - the spaces to set as children to the father space.
      • getComponents

        public List<ComponentInstLight> getComponents​(int spaceId)
        Gets the application instances present in the specified space.
        Parameters:
        spaceId - the unique identifier of a space.
        Returns:
        a list of component instances.
      • getComponentIds

        public List<String> getComponentIds​(int spaceId)
        Gets the identifiers of the application instances present in the specified space.
        Parameters:
        spaceId - the unique identifier of a space.
        Returns:
        a list of component instance identifiers.
      • getSubSpaces

        public List<SpaceInstLight> getSubSpaces​(int spaceId)
        Gets the spaces that are children of the specified space in the tree.
        Parameters:
        spaceId - the unique identifier of a space.
        Returns:
        a list of space instances.
      • addComponent

        public void addComponent​(ComponentInstLight component,
                                 int spaceId)
        Adds the specified component instance in the cache as being in the specified space.
        Parameters:
        component - a component instance.
        spaceId - the unique identifier of the space that contains the given component instance.
      • removeComponent

        public void removeComponent​(int spaceId,
                                    String componentId)
        Removes from the cache the given component instance as being in the given space.
        Parameters:
        spaceId - the unique identifier of a space.
        componentId - the unique identifier of a component instance.
      • setComponents

        public void setComponents​(int spaceId,
                                  List<ComponentInstLight> components)
        Sets the specified component instances in the cache as being in the specified space. If there is no such space, then nothing is done. If the space has already some component instances in the cache, then they are replaced by the specified ones.
        Parameters:
        spaceId - the unique identifier of a space in the cache.
        components - a list of component instances.
      • getComponentsInSpaceAndSubspaces

        public List<ComponentInstLight> getComponentsInSpaceAndSubspaces​(int spaceId)
        Gets all the component instances that are directly and indirectly contained in the specified space.
        Parameters:
        spaceId - the unique identifier of a space.
        Returns:
        a list of component instances.
      • getSpacePath

        public List<SpaceInstLight> getSpacePath​(int spaceId)
        Gets the path in the tree of the specified space.
        Parameters:
        spaceId - the unique identifier of a space.
        Returns:
        the path of a space in the cached tree.
      • getComponent

        public Optional<ComponentInstLight> getComponent​(String componentId)
        Gets the component instance with the specified identifier.
        Parameters:
        componentId - the unique identifier of a component instance.
        Returns:
        the a ComponentInstLight object.
      • getSpaceContainingComponent

        public Optional<SpaceInstLight> getSpaceContainingComponent​(String componentId)
        Gets the space that contains the specified component instance.
        Parameters:
        componentId - the unique identifier of a component instance in the cache.
        Returns:
        the SpaceInstLight instance that contains the specified component instance.
      • getComponentPath

        public List<SpaceInstLight> getComponentPath​(String componentId)
        Gets the path of the specified component instance in the cached tree.
        Parameters:
        componentId - the unique identifier of a component instance.
        Returns:
        a list of SpaceInstLight instances, each of them being a node in the path of the component instance.
      • updateSpace

        public void updateSpace​(SpaceInstLight spaceLight)
        Updates the space cached here by the specified one. The space in the cache to update is identified by the identifier of the specified space instance.
        Parameters:
        spaceLight - the instance with which the space in the cache will be updated.
      • getSpaceLevel

        public int getSpaceLevel​(int spaceId)
        Gets the level of the specified space in the cached tree.
        Parameters:
        spaceId - the unique identifier of a space in the cache.
        Returns:
        the level of the space in the tree. -1 means the space isn't cached, 0 means the space is a root one.
      • addSubSpace

        public void addSubSpace​(int spaceId,
                                SpaceInstLight subSpace)
        Adds the specified space as a child space of the space with the given identifier.
        Parameters:
        spaceId - the unique identifier of a space that will contain the given space.
        subSpace - the space to add as a child.
      • updateComponent

        public void updateComponent​(ComponentInstLight component)
        Updates the component instance cached here by the specified one. The cached component instance is found by the identifier of the given component instance. The cached component instance is replaced by the specified one.
        Parameters:
        component - the component instance with which the cached one will be updated.
      • isSpacePresent

        public boolean isSpacePresent​(int spaceId)