Imports resources that does not need to inserted in a specific order.

@throws \DreamFactory\Core\Exceptions\InternalServerErrorException
426184
protected function insertOtherResource()
    {
        $items = $this->package->getNonStorageServices();
        $imported = false;

        foreach ($items as $service => $resources) {
            foreach ($resources as $resourceName => $details) {
                try {
                    $api = $service . '/' . $resourceName;
                    switch ($api) {
                        case 'system/app':
                        case 'system/role':
                        case 'system/service':
                        case 'system/event_script':
                        case 'system/user':
                            // Skip; already imported at this point.
                            break;
                        case $service . '/_table':
                            $imported = $this->insertDbTableResources($service);
                            break;
                        case $service . '/_proc':
                        case $service . '/_func':
                            // Not supported at this time.
                            $this->log('warning', 'Skipping resource ' . $resourceName . '. Not supported.');
                            break;
                        default:
                            $imported = $this->insertGenericResources($service, $resourceName);
                            break;
                    }
                } catch (UnauthorizedException $e) {
                    $this->log(
                        'error',
                        'Failed to insert resources for ' . $service . '/' . $resourceName . '. ' . $e->getMessage()
                    );
                }
            }
        }

        return $imported;
    }
908613
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();

		// Expand config (cause %appDir% etc..)
		$config = $this->validateConfig($this->defaults);
		$config = $this->config = Helpers::expand($config, $builder->parameters);

		foreach ($config['resources'] as $namespace => $resource) {
			if (substr($namespace, -1) !== '\\') {
				throw new RuntimeException(sprintf('Resource "%s" must end with /', $namespace));
			}

			// Merge and validace resource config
			$resource = $this->validateConfig($this->resource, $resource, $namespace);

			// Normalize resource config
			if (is_scalar($resource['paths'])) $resource['paths'] = [$resource['paths']];
			if (is_scalar($resource['excludes'])) $resource['excludes'] = [$resource['excludes']];

			// Find classes of given resource
			$classes = $this->findClasses($namespace, $resource['paths'], $resource['excludes']);

			//  of given resource
			$counter = 1;
			$name = preg_replace('#\W+#', '_', '.' . $namespace);
			foreach ($classes as $class) {
				// Check already registered classes
				if ($builder->getByType($class) !== null) return;

				$def = $builder->addDefinition($this->prefix($name . '.' . ($counter++)))
					->setFactory($class);

				// Merge and validace decorator config
				$decorator = $this->validateConfig($this->decorator, $resource['decorator'], $namespace);

				if ($decorator['tags'] !== []) {
					$def->setTags(Arrays::normalize($decorator['tags'], true));
				}

				if ($decorator['setup'] !== []) {
					foreach ($decorator['setup'] as $setup) {
						if (is_array($setup)) {
							$setup = new Statement(key($setup), array_values($setup));
						}
						$def->addSetup($setup);
					}
				}

				if ($decorator['autowired'] !== null) {
					$def->setAutowired($decorator['autowired']);
				}

				if ($decorator['inject'] !== null) {
					$def->setInject($decorator['inject']);
				}
			}
		}
	}
128646
public void importArtifacts(SessionProvider sp, File folder) throws RepositoryException, FileNotFoundException
   {
      if (!folder.exists())
         throw new FileNotFoundException("Source folder expected");
      try
      {
         this.listErrorPom.clear();
         importFilesToJCR(sp, folder);
      }
      catch (Exception e)
      {
         LOG.error("Exception during uploading local folder to JCR", e);
      }
   }
765441
public function import()
    {
        DB::beginTransaction();

        try {
            $iteration = 0;

            while (! feof($this->file)) {
                $iteration++;

                $csvLine = str_getcsv(fgets($this->file), ';');
                $columnCount = count($csvLine);

                if ($columnCount === 1 && !$this->importer->validateLine($csvLine)) {
                    continue;
                } elseif ($this->importer->validateLine($csvLine)) {
                    $this->handleLine($csvLine);
                } else {
                    throw new InvalidCsvLineException($iteration);
                }
            }

            $this->lines = $this->importer->getModelInstance()->count();

            $this->removeStale();

            if (!$this->dryRun) {
                DB::commit();
            }

            event(new ImportSuccess($this, $this->importer));
        } catch (\Exception $e) {
            DB::rollBack();

            event(new ImportFailed($this, $this->importer, $e));

            // Re-throw the exception to catch it from outside
            throw $e;
        }
    }
1097337
public function initializeObject()
    {
        if (!is_dir($this->path) && !is_link($this->path)) {
            throw new Exception('The directory "' . $this->path . '" which was configured as a resource storage does not exist.', 1361533189);
        }
    }
705214
protected function addStorageFiles()
    {
        $items = $this->package->getStorageServices();
        foreach ($items as $service => $resources) {
            if (is_string($resources)) {
                $resources = explode(',', $resources);
            }
            foreach ($resources as $resourceName => $resource) {
                // If reachable flag is present and service is not reachable then skip it.
                if ($resourceName === static::REACHABLE_FLAG && $resource === false) {
                    continue;
                }

                if (Session::checkServicePermission(
                    Verbs::GET, $service, $resource, Session::getRequestor(), false
                )) {
                    /** @type FileServiceInterface $storage */
                    $storage = ServiceManager::getService($service);
                    if (!$storage) {
                        throw new InternalServerErrorException("Can not find storage service $service.");
                    }

                    if ($storage->folderExists($resource)) {
                        $zippedResource = $this->getStorageFolderZip($storage, $resource);
                        if ($zippedResource !== false) {
                            $newFileName = $service . '/' . rtrim($resource, '/') . '/' . md5($resource) . '.zip';
                            $this->package->zipFile($zippedResource, $newFileName);
                            $this->destructible[] = $zippedResource;
                        }
                    } elseif ($storage->fileExists($resource)) {
                        $content = $storage->getFileContent($resource, null, false);
                        $this->package->zipContent($service . '/' . $resource, $content);
                    }
                }
            }
        }
    }
793944
protected void importRelations(CmsResource resource, Element parentElement) {

        // Get the nodes for the relations
        @SuppressWarnings("unchecked")
        List<Node> relationElements = parentElement.selectNodes(
            "./" + A_CmsImport.N_RELATIONS + "/" + A_CmsImport.N_RELATION);

        List<CmsRelation> relations = new ArrayList<CmsRelation>();
        // iterate over the nodes
        Iterator<Node> itRelations = relationElements.iterator();
        while (itRelations.hasNext()) {
            Element relationElement = (Element)itRelations.next();
            String structureID = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_ID);
            String targetPath = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_PATH);
            String relationType = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_TYPE);
            CmsUUID targetId = new CmsUUID(structureID);
            CmsRelationType type = CmsRelationType.valueOf(relationType);

            CmsRelation relation = new CmsRelation(
                resource.getStructureId(),
                resource.getRootPath(),
                targetId,
                targetPath,
                type);

            relations.add(relation);
        }

        if (!relations.isEmpty()) {
            m_importedRelations.put(resource.getRootPath(), relations);
        }
    }
889230
public function init_resources() {

		$resources = array(
			'WC_API_Client_Resource_Coupons'       => 'coupons',
			'WC_API_Client_Resource_Custom'        => 'custom',
			'WC_API_Client_Resource_Customers'     => 'customers',
			'WC_API_Client_Resource_Index'         => 'index',
			'WC_API_Client_Resource_Orders'        => 'orders',
			'WC_API_Client_Resource_Order_Notes'   => 'order_notes',
			'WC_API_Client_Resource_Order_Refunds' => 'order_refunds',
			'WC_API_Client_Resource_Products'      => 'products',
			'WC_API_Client_Resource_Reports'       => 'reports',
			'WC_API_Client_Resource_Webhooks'      => 'webhooks',
		);

		foreach ( $resources as $resource_class => $resource_method ) {

			if ( class_exists( $resource_class ) ) {
				$this->$resource_method = new $resource_class( $this );
			}
		}
	}
134462
public function importProvider(ResourceProviderInterface $provider, array $values = [])
    {
        $provider->populate($this);
        $this->importValues($values);
    }
1338465
protected function loadResources()
    {
        $config = $this["config.service"];
        foreach (["hooks", "routes", "provider"] as $type) {
            // remnant of an old bad decission
            $confName = $type === "provider" ? "register" : "load";
            if (($config["provider.{$type}.{$confName}"] ?? false) === false) {
                continue;
            }
            if (isset($config["provider.{$type}List"]) === false
                || is_array($config["provider.{$type}List"]) === false
            ) {
                continue;
            }

            foreach ($config["provider.{$type}List"] as $class) {
                $this->register(new $class);
            }
        }
    }
815506
private function triggerTweakwiseImport()
    {
        $apiImportUrl = $this->config->getApiImportUrl();
        if (empty($apiImportUrl)) {
            $this->log->debug('TW import not triggered, no api import url defined.');
            return;
        }

        try {
            $client = new HttpClient($apiImportUrl);
            $client->send();
            $this->log->debug('TW import triggered');
        } catch (HttpClient\Exception\ExceptionInterface $e) {
            $this->log->error(sprintf('Trigger TW import failed due to %s', $e->getMessage()));
        }
    }
155944
public function import()
    {
        try {
            ini_set(
                'max_execution_time',
                '0'
            );

            clearstatcache();

            if (is_dir($this->getSearchPath())) {
                $searchPath = new \RecursiveDirectoryIterator(
                    $this->getSearchPath(),
                    \FilesystemIterator::FOLLOW_SYMLINKS
                );

                $searchFile = $this->getSearchFile();

                clearstatcache();

                if (!touch($searchFile)) {
                    throw new \Exception(
                        $searchFile . ' ' . $this->translate->translate(
                            'could not be created',
                            'mp3'
                        )
                    );
                }

                if (is_file($searchFile)) {
                    $handle = fopen(
                        $searchFile,
                        'w'
                    );

                    if (is_writable($searchFile)) {
                        if (!$handle) {
                            throw new \Exception(
                                $this->translate->translate('Cannot Open File') . ': ' . $searchFile
                            );
                        }
                    } else {
                        throw new \Exception(
                            $this->translate->translate('File Is Not Writable') . ': ' . $searchFile
                        );
                    }

                    $array = [];

                    /**
                     * @var \RecursiveDirectoryIterator $current
                     */
                    foreach (new \RecursiveIteratorIterator($searchPath) as $current) {
                        $basePathName = basename($current->getPathname());

                        if ($basePathName != '..') {
                            $fileExtension = substr(
                                strrchr(
                                    $basePathName,
                                    '.'
                                ),
                                1
                            );

                            clearstatcache();

                            /**
                             * Directory
                             */
                            if (is_dir($current->getPathname())) {
                                $directoryName = substr(
                                    $current->getPathName(),
                                    0,
                                    -2
                                );

                                $replaceDirectory = str_replace(
                                    $this->getSearchPath(),
                                    '',
                                    $directoryName
                                );

                                $directoryTrim = ltrim(
                                    $replaceDirectory,
                                    '/'
                                );

                                $array[] = $directoryTrim;
                            }

                            /**
                             * File
                             */
                            if (is_file($current->getPathname()) && in_array(
                                    '.' . $fileExtension,
                                    $this->getExtensions()
                                )
                            ) {
                                $fileName = $current->getPathname();

                                $replaceFileName = str_replace(
                                    $this->getSearchPath(),
                                    '',
                                    $fileName
                                );

                                $fileNameTrim = ltrim(
                                    $replaceFileName,
                                    '/'
                                );

                                $array[] = $fileNameTrim;
                            }
                        }
                    }

                    $result = array_unique($array);

                    sort($result);

                    fwrite(
                        $handle,
                        serialize($result)
                    );

                    fclose($handle);
                } else {
                    throw new \Exception(
                        $searchFile . ' ' . $this->translate->translate(
                            'was not found',
                            'mp3'
                        )
                    );
                }
            } else {
                throw new \Exception(
                    $this->getBaseDir() . ' ' . $this->translate->translate(
                        'was not found',
                        'mp3'
                    )
                );
            }
        } catch (\Exception $e) {
            echo $e->getMessage();
            throw $e;
        }
    }
1138135
public function buildFromRequest(ImportRequest $importRequest)
    {
        $importerId = $importRequest->getImporterId();
        $storageSelection = null;
        $sourceStorage = null;

        if ($importRequest->hasSource()) {
            $storageSelection = $this->storageLocator->selectStorage(
                $importRequest->getSourceProviderId(),
                $importRequest->getSourceId()
            );

            $sourceStorage = $this->storageLocator->getStorage($storageSelection);

            if (!$importRequest->hasImporterId()) {
                $importerId = $this->findImporterForStorage($sourceStorage);
                if (!$importerId) {
                    throw new InvalidConfigurationException('No importerId was given and there is no importer that matches the storage.');
                }

                $importRequest->setImporterId($importerId);
                $this->eventDispatcher->dispatch(
                    ImportRequestEvent::DISCOVERED,
                    new ImportRequestEvent($importRequest));
            }
        }

        $importConfiguration = new ImportConfiguration($storageSelection, $importerId);

        return $this->build($importConfiguration, $sourceStorage, $importRequest->getCreatedBy(), $importRequest->getContext());
    }
546899
public void importResource() {

        m_resourceIdWasNull = false;

        try {
            if (m_throwable != null) {
                getReport().println(m_throwable);
                getReport().addError(m_throwable);

                CmsMessageContainer message = Messages.get().container(
                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(message.key(), m_throwable);
                }
                m_throwable = null;
                m_importACEs = false;
                m_resource = null;

                return;
            }

            // apply name translation and import path
            String translatedName = getRequestContext().addSiteRoot(
                CmsStringUtil.joinPaths(m_parameters.getDestinationPath(), m_destination));

            boolean resourceImmutable = checkImmutable(translatedName);
            translatedName = getRequestContext().removeSiteRoot(translatedName);
            // if the resource is not immutable and not on the exclude list, import it
            if (!resourceImmutable) {
                // print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
                getReport().print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                        translatedName));
                getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

                boolean exists = getCms().existsResource(translatedName, CmsResourceFilter.ALL);

                byte[] content = null;
                // get the file content

                if (m_source != null) {
                    content = m_helper.getFileBytes(m_source);
                }
                int size = 0;
                if (content != null) {
                    size = content.length;
                }
                setDefaultsForEmptyResourceFields();
                // create a new CmsResource
                CmsResource resource = createResourceObjectFromFields(translatedName, size);

                if (m_resourceBuilder.getType().isFolder()
                    || m_resourceIdWasNull
                    || hasContentInVfsOrImport(resource)) {
                    // import this resource in the VFS
                    m_resource = getCms().importResource(
                        translatedName,
                        resource,
                        content,
                        new ArrayList<CmsProperty>(m_properties.values()));
                }

                if (m_resource != null) {
                    m_indexToStructureId.put(Integer.valueOf(m_fileCounter), m_resource.getStructureId());
                }

                // only set permissions if the resource did not exists or if the keep permissions flag is not set
                m_importACEs = (m_resource != null) && (!exists || !m_parameters.isKeepPermissions());

                if (m_resource != null) {
                    getReport().println(
                        org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                        I_CmsReport.FORMAT_OK);

                    if (OpenCms.getResourceManager().getResourceType(
                        m_resource.getTypeId()) instanceof I_CmsLinkParseable) {
                        // store for later use
                        m_parseables.add(m_resource);
                    }
                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_IMPORTING_4,
                                new Object[] {
                                    String.valueOf(m_fileCounter),
                                    String.valueOf(m_totalFiles),
                                    translatedName,
                                    m_destination}));
                    }
                } else {
                    // resource import failed, since no CmsResource was created
                    getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                    getReport().println(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));

                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_SKIPPING_3,
                                String.valueOf(m_fileCounter),
                                String.valueOf(m_totalFiles),
                                translatedName));
                    }
                }
            } else {
                m_resource = null;
                // skip the file import, just print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                getReport().println(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                        translatedName));

                if (LOG.isInfoEnabled()) {
                    LOG.info(
                        Messages.get().getBundle().key(
                            Messages.LOG_SKIPPING_3,
                            String.valueOf(m_fileCounter),
                            String.valueOf(m_totalFiles),
                            translatedName));
                }
                // do not import ACEs
                m_importACEs = false;
            }
        } catch (Exception e) {
            m_resource = null;
            m_importACEs = false;

            getReport().println(e);
            getReport().addError(e);

            CmsMessageContainer message = Messages.get().container(
                Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }

            return;
        }
    }
750502
public function init() {
    $mode = $this->getProject()->getProperty('includeresource.mode');
    if (!is_null($mode)) {
      $this->setMode($mode);
    }
  }
396311
protected function initializeConcreteResource()
    {
        $this->concreteResource = $this->resourceResolver->resolve($this->topic, $this->action);
    }
1360494
private function loadResourceFiles()
    {
        return $this->replaceExecutableCode(
            $this->loadResourcesFiles()
        )->mapWithKeys(function ($value, $key) {
            return [$this->removeExtension($key) => $value];
        });
    }