original_string: protected function insertGenericResources($service, $resource)
      {
          $data = $this->package->getResourceFromZip($service . '/' . $resource . '.json');
          $merged = $this->mergeSchemas($service, $resource, $data);
          $records = $this->cleanDuplicates($data, $service, $resource);
  
          if (!empty($records)) {
              try {
                  foreach ($records as $i => $record) {
                      $this->fixCommonFields($record);
                      $this->unsetImportedRelations($record);
                      $records[$i] = $record;
                  }
  
                  $payload = ResourcesWrapper::wrapResources($records);
                  $result = ServiceManager::handleRequest(
                      $service, Verbs::POST, $resource, ['continue' => true], [], $payload, null, true, true
                  );
                  if ($result->getStatusCode() >= 300) {
                      throw ResponseFactory::createExceptionFromResponse($result);
                  }
                  if ($service . '/' . $resource === 'system/admin') {
                      static::updateUserPassword($records);
                  }
  
                  return true;
              } catch (\Exception $e) {
  //                if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) {
  //                    $this->log(
  //                        'error',
  //                        'Failed to insert ' .
  //                        $service .
  //                        '/' .
  //                        $resource .
  //                        '. ' .
  //                        $this->getErrorDetails($e)
  //                    );
  //                } else {
  //                    throw new InternalServerErrorException('Failed to insert ' .
  //                        $service .
  //                        '/' .
  //                        $resource .
  //                        '. ' .
  //                        $this->getErrorDetails($e)
  //                    );
  //                }
                  $this->throwExceptions($e, 'Failed to insert ' . $service . '/' . $resource);
              }
          }
  
          return $merged;
      }
code: protected function insertGenericResources($service, $resource)
      {
          $data = $this->package->getResourceFromZip($service . '/' . $resource . '.json');
          $merged = $this->mergeSchemas($service, $resource, $data);
          $records = $this->cleanDuplicates($data, $service, $resource);
  
          if (!empty($records)) {
              try {
                  foreach ($records as $i => $record) {
                      $this->fixCommonFields($record);
                      $this->unsetImportedRelations($record);
                      $records[$i] = $record;
                  }
  
                  $payload = ResourcesWrapper::wrapResources($records);
                  $result = ServiceManager::handleRequest(
                      $service, Verbs::POST, $resource, ['continue' => true], [], $payload, null, true, true
                  );
                  if ($result->getStatusCode() >= 300) {
                      throw ResponseFactory::createExceptionFromResponse($result);
                  }
                  if ($service . '/' . $resource === 'system/admin') {
                      static::updateUserPassword($records);
                  }
  
                  return true;
              } catch (\Exception $e) {
  //                if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) {
  //                    $this->log(
  //                        'error',
  //                        'Failed to insert ' .
  //                        $service .
  //                        '/' .
  //                        $resource .
  //                        '. ' .
  //                        $this->getErrorDetails($e)
  //                    );
  //                } else {
  //                    throw new InternalServerErrorException('Failed to insert ' .
  //                        $service .
  //                        '/' .
  //                        $resource .
  //                        '. ' .
  //                        $this->getErrorDetails($e)
  //                    );
  //                }
                  $this->throwExceptions($e, 'Failed to insert ' . $service . '/' . $resource);
              }
          }
  
          return $merged;
      }
code_tokens: protected function insertGenericResources ( $ service , $ resource ) { $ data = $ this -> package -> getResourceFromZip ( $ service . '/' . $ resource . '.json' ) ; $ merged = $ this -> mergeSchemas ( $ service , $ resource , $ data ) ; $ records = $ this -> cleanDuplicates ( $ data , $ service , $ resource ) ; if ( ! empty ( $ records ) ) { try { foreach ( $ records as $ i => $ record ) { $ this -> fixCommonFields ( $ record ) ; $ this -> unsetImportedRelations ( $ record ) ; $ records [ $ i ] = $ record ; } $ payload = ResourcesWrapper :: wrapResources ( $ records ) ; $ result = ServiceManager :: handleRequest ( $ service , Verbs :: POST , $ resource , [ 'continue' => true ] , [ ] , $ payload , null , true , true ) ; if ( $ result -> getStatusCode ( ) >= 300 ) { throw ResponseFactory :: createExceptionFromResponse ( $ result ) ; } if ( $ service . '/' . $ resource === 'system/admin' ) { static :: updateUserPassword ( $ records ) ; } return true ; } catch ( \ Exception $ e ) { //                if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) { //                    $this->log( //                        'error', //                        'Failed to insert ' . //                        $service . //                        '/' . //                        $resource . //                        '. ' . //                        $this->getErrorDetails($e) //                    ); //                } else { //                    throw new InternalServerErrorException('Failed to insert ' . //                        $service . //                        '/' . //                        $resource . //                        '. ' . //                        $this->getErrorDetails($e) //                    ); //                } $ this -> throwExceptions ( $ e , 'Failed to insert ' . $ service . '/' . $ resource ) ; } } return $ merged ; }
docstring: Imports generic resources.
  
  @param string $service
  @param string $resource
  
  @return bool
  @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
docstring_tokens: Imports generic resources .