Class ReplaceInterfacesStorage


  • public class ReplaceInterfacesStorage
    extends Object
    Storage for replace interfaces.
    Since:
    7.0.0
    Version:
    $Revision: 21780 $ $Date: 2018-09-04 14:19:54 -0300 (Tue, 04 Sep 2018) $
    • Constructor Detail

      • ReplaceInterfacesStorage

        public ReplaceInterfacesStorage​(String replaceInterfacesStr)
                                 throws UnsupportedEncodingException
        Constructs a new storage with the given string.

        The string must be formatted as following:
        originInterfaceInstance=destinationInterfaceInstance(;originInterfaceInstance=destinationInterfaceInstance)*
        Where:

        • originInterfaceInstance is the original interface instance.
        • destinationInterfaceInstance is the interface instance that is replacing the original one.

        If the given string is null or empty no interface instance is being replaced.
        Parameters:
        replaceInterfacesStr - the string of replaces.
        Throws:
        UnsupportedEncodingException
        Since:
        7.0.0
    • Method Detail

      • getMap

        public Map<String,​String> getMap()
        Returns the replace map.
        Returns:
        the replace map.
        Since:
        7.0.0
      • getStackTopByExistentItem

        public String getStackTopByExistentItem​(String item)
        Returns the top of replace stack by a given item.
        Parameters:
        item - the item used to search in the map.
        Returns:
        the top of replace stack by a given item.
        Since:
        7.0.0
      • getBaseItemForItem

        public String getBaseItemForItem​(String item)
        Returns the base item (root item) that is being replaced for the given item.
        Parameters:
        item - the item used to search in the map.
        Returns:
        the base item.
        Since:
        7.1.1
      • remove

        public String remove​(String item)
        Removes the given interface instance from the replace map (searching it as the mapping key).
        Parameters:
        item - the item to be removed.
        Returns:
        the result of Map.remove(Object).
        Since:
        7.0.0
      • put

        public String put​(String source,
                          String target)
        Creates a new replace mapping source -> target.
        Parameters:
        source - the interface instance that is going to be replaced.
        target - the interface instance that is going to replace.
        Returns:
        the result of Map.put(Object, Object).
        Since:
        7.0.0
      • handleReplaceInterfaceOperations

        public String handleReplaceInterfaceOperations​(String currentInterfaceInstanceId,
                                                       String[] replaceInterfaceOperations,
                                                       PortalRequestParameters parameters)
                                                throws PortalException
        Handles the replace interface commands. Also applies the properly parameters in PortalRequestParameters if needed. Returns the result interface instance after the commands are applied. The commands are formatted in a string array. Each command string may have multiple commands separated by a ',' character.

        The supported commands are:

        • r: removes the current interface instance from the replaces map. After this command is executed, the current interface instance becomes the one that it was replacing.
          In other words, if the current interface instance is II-2, there is an interface instance II-1 such that II-2 is replacing II-1 and a command r is executed, the current interface instance becomes II-1.
        • a: this command adds a new replace mapping. It must be followed by the interface instance that is going to replace the current interface instance. After this command is executed, the current interface instance becomes the given one.
          In other words, if II-1 is the current interface instance and the command aII-2 is executed, the interface instance II-2 replaces the interface instance II-1 and II-2 becomes the current interface instance.

        Parameters:
        currentInterfaceInstanceId - the current interface instance.
        replaceInterfaceOperations - the replace commands array.
        parameters - the replace interface parameters.
        Returns:
        the result interface instance after the commands are applied.
        Throws:
        PortalException
        Since:
        7.0.0
      • getReplaceInterfaceParametersParameterName

        protected String getReplaceInterfaceParametersParameterName()