public static function executeImportRecords(Application $app, Request $request, $contentTypeAccessHash, Module $module = null)
 {
     /** @var Repository $repository */
     $repository = $app['repos']->getRepositoryByContentTypeAccessHash($contentTypeAccessHash);
     $success = false;
     $filename = null;
     if ($repository) {
         $contentTypeDefinition = $repository->getContentTypeDefinition();
         $app['context']->setCurrentRepository($repository);
         $app['context']->setCurrentContentType($contentTypeDefinition);
         $workspace = $request->get('workspace');
         if (!$contentTypeDefinition->hasWorkspace($workspace)) {
             $workspace = 'default';
         }
         $language = $request->get('language');
         if (!$contentTypeDefinition->hasLanguage($language)) {
             $language = 'default';
         }
         $format = $request->get('format');
         if ($request->files->get('file')) {
             /** @var UploadedFile $uploadedFile */
             $uploadedFile = $request->files->get('file');
             if ($uploadedFile->isValid()) {
                 $filename = $uploadedFile->getClientOriginalName();
                 $importer = new Importer();
                 $importer->setTruncateRecords((bool) $request->get('truncate'));
                 $importer->setGenerateNewIDs((bool) $request->get('newids'));
                 $importer->setPropertyChangesCheck((bool) $request->get('propertyupdate'));
                 $importer->setNewerRevisionUpdateProtection((bool) $request->get('protectedrevisions'));
                 set_time_limit(0);
                 if ($format == 'j') {
                     $data = file_get_contents($uploadedFile->getRealPath());
                     if ($data) {
                         if ($importer->importJSON($repository, $contentTypeDefinition->getName(), $data, $workspace, $language)) {
                             $success = true;
                         }
                     }
                 } else {
                     if ($importer->importXLSX($repository, $contentTypeDefinition->getName(), $uploadedFile->getRealPath(), $workspace, $language)) {
                         $success = true;
                     }
                 }
             }
         } else {
             $app['context']->addInfoMessage('Did you actually upload a file? Nothing here.');
         }
     }
     if ($success) {
         $app['context']->addSuccessMessage($importer->getCount() . ' record(s) imported from ' . $filename);
     } else {
         $app['context']->addErrorMessage('Could not import records.');
     }
     return new RedirectResponse($app['url_generator']->generate('listRecords', array('contentTypeAccessHash' => $contentTypeAccessHash, 'page' => $app['context']->getCurrentListingPage(), 'workspace' => $app['context']->getCurrentWorkspace(), 'language' => $app['context']->getCurrentLanguage())));
 }