public function indexAction()
 {
     $dumpItem = new $this->_modelClass();
     $this->_helper->allowed('list', $dumpItem);
     $params = $this->getRequest()->getQuery();
     if (isset($params[static::REQUEST_FIELDS_PARAM])) {
         $fields = explode(':', $params[static::REQUEST_FIELDS_PARAM]);
         unset($params[static::REQUEST_FIELDS_PARAM]);
     }
     if (isset($params[static::REQUEST_AVOID_FIELDS_PARAM])) {
         $avoidFields = explode(':', $params[static::REQUEST_AVOID_FIELDS_PARAM]);
         unset($params[static::REQUEST_AVOID_FIELDS_PARAM]);
     }
     if (isset($params[static::REQUEST_SKIP_EMPTY_ITEMS_PARAM])) {
         if ($params[static::REQUEST_SKIP_EMPTY_ITEMS_PARAM]) {
             $skipEmptyItems = true;
         }
         unset($params[static::REQUEST_SKIP_EMPTY_ITEMS_PARAM]);
     }
     $output = null;
     if (isset($params[static::OUTPUT_PARAM])) {
         $output = $params[static::OUTPUT_PARAM];
         unset($params[static::OUTPUT_PARAM]);
     }
     switch ($output) {
         case 'csv':
             $this->_helper->output('stream_Csv')->setFilename(strtolower($this->_getName()) . '.csv');
             $commonHeaders = $this->_helper->csv()->getHeaders(strtolower($this->_getName()));
             if (isset($fields)) {
                 $commonHeaders = $this->_helper->filter($commonHeaders, $fields);
             }
             $commonHeaders = $this->_helper->filterNotAllowedExportFields('read_field', $dumpItem, $commonHeaders);
             $this->view->setHeaders($commonHeaders);
             $headersFilters = $this->_helper->csv()->getFilters(strtolower($this->_getName()));
             $this->view->setFilters($headersFilters);
             break;
         default:
             $this->_helper->output('stream_Json');
             break;
     }
     $paging = $this->_getPaging($params);
     $filterList = $this->_getFilterList($params);
     $this->_helper->filterNotAllowedFilters('filter_by', $filterList);
     $this->_helper->filterNotAllowedGroupBy('group_by', $filterList);
     $this->_helper->filterNotAllowedSortBy('sort_by', $filterList);
     $itemList = $this->_service->listAll($filterList, array('paging' => $paging));
     if (isset($fields)) {
         $this->view->setAllowedFields($fields);
     }
     if (isset($skipEmptyItems)) {
         $this->view->setSkipEmptyItems($skipEmptyItems);
     }
     if ($itemList instanceof StreamResultModel) {
         $itemList->getIterator()->addPlugin(new Allowed(array('permission' => 'read')), 'allowed');
         $itemList->getIterator()->addPlugin(new FilterNotAllowedFields(array('permission' => 'read_field')), 'filterNotAllowedFields');
         if (isset($avoidFields)) {
             $itemList->getIterator()->addPlugin(new AvoidFields(array('fields' => $avoidFields)), 'avoid');
         }
         $itemList->getIterator()->init();
     } else {
         if ($itemList instanceof Application\Model\GroupListModel) {
             /*
              * TODO Needs a refactor to use stream also in groups
              */
             $this->_helper->output('json');
             if ($groups = $itemList->getGroups()) {
                 foreach ($groups as $group) {
                     $items = array();
                     foreach ($group as $key => $item) {
                         try {
                             $this->_helper->allowed('read', $item);
                             $this->_helper->filterNotAllowedFields('read_field', $item);
                             $items[] = $item;
                         } catch (\Application\Exceptions\ForbiddenException $e) {
                             //
                         }
                     }
                     $group->setItems($items);
                 }
             }
         }
     }
     $this->_preList($itemList);
     $this->view->data = $itemList;
     $this->_helper->output()->addHeaders();
     $this->getResponse()->sendHeaders();
     $this->view->setCountKey($this->viewCountKey);
     $this->view->setDataKey($this->viewDataKey);
     $this->view->render("");
     $this->_helper->forceExit();
 }