package io.cloudslang.content.actions;

import com.hp.oo.sdk.content.annotations.Action;
import com.hp.oo.sdk.content.annotations.Output;
import com.hp.oo.sdk.content.annotations.Param;
import com.hp.oo.sdk.content.annotations.Response;
import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType;
import com.hp.oo.sdk.content.plugin.ActionMetadata.ResponseType;
import com.hp.oo.sdk.content.plugin.GlobalSessionObject;
import io.cloudslang.content.services.ListService;

import java.util.Map;

public class ListIteratorAction {

    /**
     * This operation is used to retrieve a value from a list. When the index of an element from a list is known,
     * this operation can be used to extract the element.
     *
     * @param list      The list to get the value from.
     * @param delimiter The delimiter that separates values in the list.
     * @param index     The index of the value (starting with 0) to retrieve from the list.
     * @return It returns the value found at the specified index in the list, if the value specified for
     * the @index parameter is positive and less than the size of the list. Otherwise, it returns
     * the value specified for @index.
     */
    @Action(name = "List Iterator",
            outputs = {
                    @Output("resultString"),
                    @Output("result")},
            responses = {
                    @Response(text = "has more", field = "result", value = "has more", matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                    @Response(text = "no more", field = "result", value = "no more", matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                    @Response(text = "failure", field = "result", value = "failure", matchType = MatchType.COMPARE_EQUAL, isDefault = true, isOnFail = true)})
    public Map<String, String> execute(@Param("list") String list,
                                       @Param("separator") String separator,
                                       @Param("globalSessionObject") GlobalSessionObject<Map<String, Object>> globalSessionObject) {
        return ListService.iterate(list, separator, globalSessionObject);
    }
}

@@ -569,145 +569,219 @@
  to 
-retrieve a value from a list. When the index of an element from a li
+iterate a list of values with the help of GlobalSessionObject in order to keep track of the la
 st 
+index. It 
 is 
-k
 no
-wn,%0A     * this operation can be used to extract the element
+t recommended to modify the value of the %22list%22 and %22separator%22 inputs during the iteration process
 .%0A  
@@ -825,26 +825,23 @@
  to 
-get the value from
+iterate through
 .%0A  
@@ -856,21 +856,19 @@
 ram 
-delimiter The
+separator A
  del
@@ -878,32 +878,18 @@
 ter 
-that 
 separat
-es values 
 in
+g
  the
@@ -897,342 +897,225 @@
 list
-.%0A     * @param index     Th
+ elements. This may b
 e 
+s
 in
-dex of the value (starting with 0) to retrieve from the list.%0A     * @return It returns the value found at the specified index in the list, if the value specified for%0A     * the @index parameter is positive and less than the size of the list. Otherwise, it returns%0A     * the value specified for @index
+gle character, multi-characters or special characters.%0A     *                  Default value: %E2%80%98,%E2%80%99 (comma).%0A     * @return resultString The current list element (if the response is %22has more%22)
 .%0A  
@@ -1227,47 +1227,8 @@
 ng%22)
-,%0A                    @Output(%22result%22)
 %7D,%0A 

Update description for ListIteratorAction