Validates the module file to be imported.<p>
421294
protected void validateModuleFile() {

        try {
            m_importFile.loadAndValidate();
            CmsModule importModule = m_importFile.getModule();
            String site = importModule.getSite();
            if (site != null) {
                if (importModule.hasImportSite()) {
                    getSiteSelector().setEnabled(false);
                    getSiteSelector().setValue(site);
                } else {
                    String itemId = CmsVaadinUtils.getPathItemId(getSiteSelector().getContainerDataSource(), site);
                    if (itemId != null) {
                        getSiteSelector().setValue(itemId);
                    }
                }
            }
            getOkButton().setEnabled(true);
        } catch (Exception e) {
            LOG.info(e.getLocalizedMessage(), e);
            m_importFile = null;
            getOkButton().setEnabled(false);
            CmsErrorDialog.showErrorDialog(e);

        }
    }
457044
private void findModulesFromInput(
      CompilerInput input,
      boolean wasImportedByModule,
      Set<CompilerInput> inputs,
      Map<String, CompilerInput> inputsByIdentifier,
      Map<String, CompilerInput> inputsByProvide,
      boolean supportEs6Modules,
      boolean supportCommonJSModules) {
    if (!inputs.remove(input)) {
      // It's possible for a module to be included as both a script
      // and a module in the same compilation. In these cases, it should
      // be forced to be a module.
      if (wasImportedByModule && input.getJsModuleType() == CompilerInput.ModuleType.NONE) {
        input.setJsModuleType(CompilerInput.ModuleType.IMPORTED_SCRIPT);
      }
      return;
    }

    FindModuleDependencies findDeps =
        new FindModuleDependencies(
            this, supportEs6Modules, supportCommonJSModules, inputPathByWebpackId);
    findDeps.process(checkNotNull(input.getAstRoot(this)));

    // If this input was imported by another module, it is itself a module
    // so we force it to be detected as such.
    if (wasImportedByModule && input.getJsModuleType() == CompilerInput.ModuleType.NONE) {
      input.setJsModuleType(CompilerInput.ModuleType.IMPORTED_SCRIPT);
    }
    this.moduleTypesByName.put(input.getPath().toModuleName(), input.getJsModuleType());

    Iterable<String> allDeps =
        Iterables.concat(
            input.getRequiredSymbols(), input.getDynamicRequires(), input.getTypeRequires());
    for (String requiredNamespace : allDeps) {
      CompilerInput requiredInput = null;
      boolean requiredByModuleImport = false;
      if (inputsByProvide.containsKey(requiredNamespace)) {
        requiredInput = inputsByProvide.get(requiredNamespace);
      } else if (inputsByIdentifier.containsKey(requiredNamespace)) {
        requiredByModuleImport = true;
        requiredInput = inputsByIdentifier.get(requiredNamespace);
      }

      if (requiredInput != null) {
        findModulesFromInput(
            requiredInput,
            requiredByModuleImport,
            inputs,
            inputsByIdentifier,
            inputsByProvide,
            supportEs6Modules,
            supportCommonJSModules);
      }
    }
  }
67743
public function validateModuleID()
    {
        if (!empty($this->moduleID)) {
            $module = Yii::$app->getModule($this->moduleID);
            if ($module === null) {
                $this->addError('moduleID', "Module '{$this->moduleID}' does not exist.");
            }
        }
    }
930495
private void updateValidation() {

        boolean changed = false;
        changed |= CmsVaadinUtils.updateComponentError(m_textField, null);
        String path = getValue();
        if (!CmsStringUtil.isEmptyOrWhitespaceOnly(path)) {
            if (!m_cms.existsResource(path, CmsResourceFilter.IGNORE_EXPIRATION)) {
                ErrorMessage error = new UserError(
                    CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_MODULE_RESOURCE_NOT_FOUND_0),
                    ContentMode.TEXT,
                    ErrorLevel.WARNING);
                changed |= CmsVaadinUtils.updateComponentError(m_textField, error);
            }
        }
        if (changed) {
            fireEvent(new Component.ErrorEvent(null, this));
        }
    }
530004
function isImported(source, classifiedName, importPath) {
    const allNodes = getSourceNodes(source);
    const matchingNodes = allNodes
        .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
        .filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
        .filter((imp) => {
        return imp.moduleSpecifier.text === importPath;
    })
        .filter((imp) => {
        if (!imp.importClause) {
            return false;
        }
        const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter(n => n.getText() === classifiedName);
        return nodes.length > 0;
    });
    return matchingNodes.length > 0;
}
1072273
private void checkFileType() {

        if ((m_fileInput != null) && (m_replaceInfo != null) && (m_fileWidget != null)) {
            CmsFileInfo file = m_fileInput.getFiles()[0];
            if (!m_replaceInfo.getSitepath().endsWith(file.getFileSuffix())) {
                Widget warningImage = FontOpenCms.WARNING.getWidget(
                    20,
                    I_CmsConstantsBundle.INSTANCE.css().colorWarning());
                warningImage.setTitle(Messages.get().key(Messages.GUI_REPLACE_WRONG_FILE_EXTENSION_0));
                warningImage.addStyleName(
                    org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().permaVisible());
                m_fileWidget.addButton(warningImage);
            }
        }
    }
511271
public static boolean checkConfiguredInModules() {

        Boolean result = m_moduleCheckCache.get();
        if (result == null) {
            result = Boolean.valueOf(getConfiguredTemplateMapping() != null);
            m_moduleCheckCache.set(result);
        }
        return result.booleanValue();
    }
220568
public void addSelectableModule(final String moduleName) {

        boolean enabled = true; /* OpenCms.getModuleManager().hasModule(moduleName); */
        CheckBox moduleCheckBox = new CheckBox();
        String iconUri = CmsWorkplace.getResourceUri("tools/modules/buttons/modules.png");
        CmsResourceInfo info = new CmsResourceInfo(moduleName, "", iconUri);
        HorizontalLayout line = new HorizontalLayout();
        line.setWidth("100%");
        line.addComponent(moduleCheckBox);
        info.setWidth("100%");
        line.addComponent(info);
        line.setComponentAlignment(moduleCheckBox, Alignment.MIDDLE_CENTER);
        line.setExpandRatio(info, 1.0f);
        moduleCheckBox.setEnabled(true);
        moduleCheckBox.setValue(Boolean.valueOf(enabled)); // If enabled, then checked by default
        m_moduleCheckboxes.put(moduleName, moduleCheckBox);
        m_moduleSelectionContainer.addComponent(line, m_moduleSelectionContainer.getComponentCount() - 1);
        setTab(m_dialogTab);
    }
891475
function checkImport(jsonImport, importType) {
        if (!jsonImport) {
            return 'Import should always be a valid JSON object!';
        }

        switch (importType) {
            case CONSTANTS.EXPORT_TYPE_PROJECT:
                if (jsonImport._metadata && jsonImport._metadata.type) {
                    if (jsonImport._metadata.type !== CONSTANTS.EXPORT_TYPE_PROJECT) {
                        return 'Import is of type \'' + CONSTANTS.EXPORT_TYPE_LIBRARY + '\' and not of \'' +
                            CONSTANTS.EXPORT_TYPE_PROJECT + '\'!';
                    }
                } else if (jsonImport.root && typeof jsonImport.root.path === 'string') {
                    if (jsonImport.root.path !== '') {
                        return 'Import is of type \'' + CONSTANTS.EXPORT_TYPE_LIBRARY + '\' and not of \'' +
                            CONSTANTS.EXPORT_TYPE_PROJECT + '\'!';
                    }
                } else {
                    return 'Import data is probably incomplete and should not be used!';
                }
                break;
            case CONSTANTS.EXPORT_TYPE_LIBRARY:
                if (jsonImport._metadata && jsonImport._metadata.type) {
                    if (jsonImport._metadata.type !== CONSTANTS.EXPORT_TYPE_LIBRARY) {
                        return 'Import is of type \'' + CONSTANTS.EXPORT_TYPE_PROJECT + '\' and not of \'' +
                            CONSTANTS.EXPORT_TYPE_LIBRARY + '\'!';
                    }
                } else if (jsonImport.root && typeof jsonImport.root.path === 'string') {
                    if (jsonImport.root.path === '') {
                        return 'Import is of type \'' + CONSTANTS.EXPORT_TYPE_PROJECT + '\' and not of \'' +
                            CONSTANTS.EXPORT_TYPE_LIBRARY + '\'!';
                    }
                } else {
                    return 'Import data is probably incomplete and should not be used!';
                }
                break;
            default:
                return 'Invalid type, cannot checked!';
        }

        return null;
    }
716691
@SuppressWarnings("resource")
    private boolean importModules() {

        boolean result = true;

        try {
            m_logStream.println("Checking module dependencies.");
            Multimap<String, String> dependencies = HashMultimap.create();
            Set<String> unsortedModules = Sets.newHashSet(m_modulesToExport);
            for (String module : m_modulesToExport) {
                String manifestPath = CmsStringUtil.joinPaths(
                    m_currentConfiguration.getModulesPath(),
                    module,
                    m_currentConfiguration.getResourcesSubFolder(),
                    "manifest.xml");
                Document doc = CmsXmlUtils.unmarshalHelper(
                    CmsFileUtil.readFully(new FileInputStream(manifestPath)),
                    new CmsXmlEntityResolver(null));

                List<?> depNodes = doc.getRootElement().selectNodes("//dependencies/dependency/@name");
                for (Object nodeObj : depNodes) {
                    Node node = ((Node)nodeObj);
                    String dependency = node.getText();
                    if (m_modulesToExport.contains(dependency)) {
                        // we can only handle dependencies between selected modules
                        // and just have to assume that other dependencies are fulfilled
                        dependencies.put(module, dependency);
                    }
                }
            }
            List<String> sortedModules = Lists.newArrayList();
            // if there are no cycles, this loop will find one element on each iteration
            for (int i = 0; i < m_modulesToExport.size(); i++) {
                String nextModule = null;
                for (String key : unsortedModules) {
                    if (dependencies.get(key).isEmpty()) {
                        nextModule = key;
                        break;
                    }
                }
                if (nextModule != null) {
                    sortedModules.add(nextModule);
                    unsortedModules.remove(nextModule);
                    for (String key : Sets.newHashSet(dependencies.keySet())) { // copy key set to avoid concurrent modification exception
                        dependencies.get(key).remove(nextModule);
                    }
                }
            }
            m_logStream.println("Modules sorted by dependencies: " + sortedModules);
            for (String moduleName : sortedModules) {
                String dir = CmsStringUtil.joinPaths(
                    m_currentConfiguration.getModulesPath(),
                    moduleName,
                    m_currentConfiguration.getResourcesSubFolder());
                File dirEntry = new File(dir);
                if (!dirEntry.exists()) {
                    continue;
                }
                try {
                    m_logStream.println("Creating temp file for module " + moduleName);
                    File outputFile = File.createTempFile(moduleName + "-", ".zip");
                    FileOutputStream fos = new FileOutputStream(outputFile);
                    m_logStream.println("Zipping module structure to " + outputFile.getAbsolutePath());
                    zipRfsFolder(dirEntry, fos);
                    result &= importModule(outputFile);
                    outputFile.delete();
                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                    e.printStackTrace(m_logStream);
                    result = false;
                }
            }
        } catch (Exception e) {

            LOG.error(e.getLocalizedMessage(), e);
            m_logStream.println("Unable to check dependencies for modules, giving up.");
            e.printStackTrace(m_logStream);
            result = false;
        }
        return result;
    }
1078414
public void updateModuleFromDefault(String importFile) throws Exception {

        String exportPath = OpenCms.getSystemInfo().getPackagesRfsPath();
        String fileName = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(
            exportPath + CmsSystemInfo.FOLDER_MODULES + importFile);
        updateModule(fileName);
    }
480932
private void validateBeforeStart() {
        LibraryUtils.checkArgumentNotNull(config, "Configuration is null.");
        config.validate();

        LibraryUtils.checkArgumentNotNull(sourceFilter, "sourceFilter is null.");
        LibraryUtils.checkArgumentNotNull(eventFilter, "eventFilter is null.");
        LibraryUtils.checkArgumentNotNull(eventsProcessor, "eventsProcessor is null.");
        LibraryUtils.checkArgumentNotNull(progressReporter, "progressReporter is null.");
        LibraryUtils.checkArgumentNotNull(exceptionHandler, "exceptionHandler is null.");

        LibraryUtils.checkArgumentNotNull(scheduledThreadPool, "scheduledThreadPool is null.");
        LibraryUtils.checkArgumentNotNull(mainThreadPool, "mainThreadPool is null.");
        LibraryUtils.checkArgumentNotNull(readerFactory, "readerFactory is null.");
    }
212851
protected void importUserFromFile() {

        CmsImportUserThread thread = new CmsImportUserThread(
            m_cms,
            m_ou,
            m_userImportList,
            getGroupsList(m_importGroups, true),
            getRolesList(m_importRoles, true),
            m_sendMail.getValue().booleanValue());
        thread.start();
        CmsShowReportDialog dialog = new CmsShowReportDialog(thread, new Runnable() {

            public void run() {

                m_window.close();
            }
        });
        m_window.setContent(dialog);

    }
201759
public void replaceModule(String importFile) throws Exception {

        OpenCms.getModuleManager().replaceModule(
            m_cms,
            importFile,
            new CmsShellReport(m_cms.getRequestContext().getLocale()));

    }
967834
public static void validateScriptsCombination(Set<XmLepResourceSubType> scriptTypes,
                                                  LepMethod lepMethod,
                                                  UrlLepResourceKey compositeResourceKey) {
        byte mask = getCombinationMask(scriptTypes, lepMethod, compositeResourceKey);

        StringBuilder errors = new StringBuilder();
        if (isZero(mask, ZERO_PATTERN_NO_TENANT_AND_DEFAULT_AND_JAVA_CODE)) {
            errors.append(String.format("Has no one script of '%s', '%s' or native (java) implementation.",
                                        XmLepResourceSubType.TENANT, XmLepResourceSubType.DEFAULT));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_BEFORE)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.BEFORE, XmLepResourceSubType.AROUND));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_AFTER)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.AROUND, XmLepResourceSubType.AFTER));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_TENANT)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Unallowed combination '%s' and '%s' scripts.", XmLepResourceSubType.AROUND, XmLepResourceSubType.TENANT));
        }

        if (errors.length() > 0) {
            throw new IllegalArgumentException(String.format("Resource key %s has script combination errors. %s",
                                                             compositeResourceKey,
                                                             errors.toString()));

        }
    }
1184450
public void validate() {
    StringBuilder validationErrorBuilder = new StringBuilder("Process engine configuration is invalid: \n");
    boolean isValid = true;    
    
    if(datasourceJndiName == null || datasourceJndiName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'datasource' cannot be null \n");      
    }
    if(engineName == null || engineName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'engineName' cannot be null \n");
    }

    for (int i = 0; i < pluginConfigurations.size(); i++) {
      ProcessEnginePluginXml pluginConfiguration = pluginConfigurations.get(i);
      if (pluginConfiguration.getPluginClass() == null || pluginConfiguration.getPluginClass().isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'class' in plugin[" + i + "] cannot be null \n");
      }
    }
    
    if(!isValid) {
      throw new ProcessEngineException(validationErrorBuilder.toString());
    }
  }
360508
protected void validateProjectFile() 
            throws MojoExecutionException
    {
        if ( projectFile != null
                && projectFile.exists()
                && projectFile.isFile() )
        {
            getLog().debug( "Project file validated at " + projectFile );

            boolean solutionFile = projectFile.getName().toLowerCase().endsWith( "." + SOLUTION_EXTENSION ); 
            if ( ( MSBuildPackaging.isSolution( mavenProject.getPackaging() ) && ! solutionFile )
                    || ( ! MSBuildPackaging.isSolution( mavenProject.getPackaging() ) && solutionFile ) )
            {
                // Solution packaging defined but the projectFile is not a .sln
                String msg = "Packaging doesn't match project file type. "
                        + "If you specify a solution file then packaging must be " + MSBuildPackaging.MSBUILD_SOLUTION;
                getLog().error( msg );
                throw new MojoExecutionException( msg );
            }
            return;
        }
        String prefix = "Missing projectFile";
        if ( projectFile != null )
        {
            prefix = ". The specified projectFile '" + projectFile
                    + "' is not valid";
        }
        throw new MojoExecutionException( prefix
                + ", please check your configuration" );
    }