Validates a component associated with the Puppet installer.
@param applicationFilesDirectory the application's directory
@param component the component
@return a non-null list of errors
421286
private static List<ModelError> validatePuppetComponent( File applicationFilesDirectory, Component component ) {
		List<ModelError> result = new ArrayList<> ();

		// Check imports
		for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( component ).values()) {
			if( var.getName().endsWith( "." + Constants.WILDCARD )) {
				result.add( new ModelError( ErrorCode.REC_PUPPET_DISLIKES_WILDCARD_IMPORTS, component, component( component )));
				break;
			}
		}

		// There must be a Puppet module that starts with "roboconf_"
		File directory = ResourceUtils.findInstanceResourcesDirectory( applicationFilesDirectory, component );
		File[] children = directory.listFiles();
		children = children == null ? new File[ 0 ] : children;
		List<File> modules = new ArrayList<> ();
		for( File f : children ) {
			if( f.isDirectory() && f.getName().toLowerCase().startsWith( "roboconf_" ))
				modules.add( f );
		}

		if( modules.isEmpty())
			result.add( new ModelError( ErrorCode.REC_PUPPET_HAS_NO_RBCF_MODULE, component, component( component )));
		else if( modules.size() > 1 )
			result.add( new ModelError( ErrorCode.REC_PUPPET_HAS_TOO_MANY_RBCF_MODULES, component, component( component )));

		// Analyze the module parameters
		if( modules.size() == 1 ) {
			File pp1 = new File( modules.get( 0 ), "manifests/update.pp" );
			File pp2 = new File( modules.get( 0 ), "manifests/init.pp" );
			File withUpdateParams = pp1.exists() ? pp1 : pp2;

			// Validate the files
			children = new File( modules.get( 0 ), "manifests" ).listFiles();
			children = children == null ? new File[ 0 ] : children;
			for( File f : children ) {
				try {
					if( f.isFile() && f.getName().toLowerCase().endsWith( ".pp" ))
						checkPuppetFile( f, f.equals( withUpdateParams ), component, result );

				} catch( IOException e ) {
					Logger logger = Logger.getLogger( RecipesValidator.class.getName());
					logger.warning( "The content of the Puppet file '" + f + "' could not be read." );
					Utils.logException( logger, e );
				}
			}
		}

		return result;
	}
1000455
@SuppressWarnings("unchecked")
   private void verifyBeanValidation(Deployment deployment) throws DeployException
   {
      if (beanValidation != null)
      {
         ValidatorFactory vf = null;

         try
         {
            vf = beanValidation.getValidatorFactory();
            javax.validation.Validator v = vf.getValidator();

            Collection<String> l = deployment.getActivation().getBeanValidationGroups();
            if (l == null || l.isEmpty())
               l = Arrays.asList(javax.validation.groups.Default.class.getName());

            Collection<Class<?>> groups = new ArrayList<>();
            for (String clz : l)
            {
               try
               {
                  groups.add(Class.forName(clz, true, deployment.getClassLoader()));
               }
               catch (ClassNotFoundException e)
               {
                  throw new DeployException(bundle.unableToLoadBeanValidationGroup(clz, deployment.getIdentifier()),
                        e);
               }
            }
         
            Set failures = new HashSet();

            if (deployment.getResourceAdapter() != null)
            {

               Set f = v.validate(deployment.getResourceAdapter().getResourceAdapter(),
                     groups.toArray(new Class<?>[groups.size()]));
               if (!f.isEmpty())
                  failures.addAll(f);

            }
            if (deployment.getConnectionFactories() != null)
            {
               for (org.ironjacamar.core.api.deploymentrepository.ConnectionFactory cf :
                       deployment.getConnectionFactories())
               {

                  Set f = v.validate(cf.getConnectionFactory(), groups.toArray(new Class<?>[groups.size()]));
                  if (!f.isEmpty())
                     failures.addAll(f);

               }
            }
            if (deployment.getAdminObjects() != null)
            {
               for (org.ironjacamar.core.api.deploymentrepository.AdminObject ao :
                       deployment.getAdminObjects())
               {

                  Set f = v.validate(ao.getAdminObject(), groups.toArray(new Class<?>[groups.size()]));
                  if (!f.isEmpty())
                     failures.addAll(f);

               }
            }
         
            if (!failures.isEmpty())
            {
               throw new DeployException(bundle.violationOfValidationRule(deployment.getIdentifier()),
                     new ConstraintViolationException(failures));
            }
         }
         finally
         {
            if (vf != null)
               vf.close();
         }
      }
   }
1176247
public static List<ModelError> parseTargetProperties( File projectDirectory, Component c ) {

		List<ModelError> errors;
		File dir = ResourceUtils.findInstanceResourcesDirectory( projectDirectory, c );
		if( dir.isDirectory()
				&& ! Utils.listAllFiles( dir, Constants.FILE_EXT_PROPERTIES ).isEmpty())
			errors = parseDirectory( dir, c );
		else
			errors = new ArrayList<>( 0 );

		return errors;
	}
1005531
protected void addComponentsFromPath(String fileName) throws CmsConfigurationException {

        CmsParameterConfiguration configuration;
        try {
            configuration = getComponentsProperties(fileName);
        } catch (FileNotFoundException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
            return;
        }

        for (String componentId : configuration.getList(PROPKEY_COMPONENTS)) {
            CmsSetupComponent componentBean = new CmsSetupComponent();
            componentBean.setId(componentId);
            componentBean.setName(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_NAME));
            componentBean.setDescription(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_DESCRIPTION));
            componentBean.setModulesRegex(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_MODULES));
            componentBean.setDependencies(
                configuration.getList(PROPKEY_COMPONENT + componentId + PROPKEY_DEPENDENCIES));
            componentBean.setPosition(
                configuration.getInteger(PROPKEY_COMPONENT + componentId + PROPKEY_POSITION, DEFAULT_POSITION));
            componentBean.setChecked(
                configuration.getBoolean(PROPKEY_COMPONENT + componentId + PROPKEY_CHECKED, false));
            m_components.addIdentifiableObject(componentBean.getId(), componentBean, componentBean.getPosition());
        }
    }
1199395
public static void validateDirectory(File topIndexDir) {
    if (!topIndexDir.exists() || !topIndexDir.isDirectory()) {
      throw new RuntimeException("Not found or is not a directory:\n" +
              topIndexDir + "\n" +
              "As ngram directory, please select the directory that has a subdirectory like 'en'\n" +
              "(or whatever language code you're using).");
    }
    List<String> dirs = new ArrayList<>();
    for (String name : topIndexDir.list()) {
      if (name.matches("[123]grams")) {
        dirs.add(name);
      }
    }
    if (dirs.isEmpty()) {
      throw new RuntimeException("Directory must contain at least '1grams', '2grams', and '3grams': " + topIndexDir.getAbsolutePath());
    }
    if (dirs.size() < 3) {
      throw new RuntimeException("Expected at least '1grams', '2grams', and '3grams' sub directories but only got " + dirs + " in " + topIndexDir.getAbsolutePath());
    }
  }
149908
private static List<ModelError> validateScriptComponent( File applicationFilesDirectory, Component component ) {
		List<ModelError> result = new ArrayList<> ();

		// There must be a "scripts" directory
		File directory = ResourceUtils.findInstanceResourcesDirectory( applicationFilesDirectory, component );
		List<File> subDirs = Utils.listAllFiles( directory );

		if( !subDirs.isEmpty()) {
			File scriptsDir = new File( directory, SCRIPTS_DIR_NAME );
			if( ! scriptsDir.exists())
				result.add( new ModelError( ErrorCode.REC_SCRIPT_NO_SCRIPTS_DIR, component, component( component )));
		}

		return result;
	}
667624
public void validateAppEngineJavaComponents()
      throws AppEngineJavaComponentsNotInstalledException {
    if (!Files.isDirectory(getAppEngineSdkForJavaPath())) {
      throw new AppEngineJavaComponentsNotInstalledException(
          "Validation Error: Java App Engine components not installed."
              + " Fix by running 'gcloud components install app-engine-java' on command-line.");
    }
    if (!Files.isRegularFile(jarLocations.get(JAVA_TOOLS_JAR))) {
      throw new AppEngineJavaComponentsNotInstalledException(
          "Validation Error: Java Tools jar location '"
              + jarLocations.get(JAVA_TOOLS_JAR)
              + "' is not a file.");
    }
  }
426733
private void validateResource(List<ValidationMessage> errors, Element resource, Element element, StructureDefinition profile, IdStatus idstatus, NodeStack stack) throws FHIRException, FHIRException {
		assert stack != null;
		assert resource != null;

		// getting going - either we got a profile, or not.
		boolean ok = true;
		if (ok) {
			String resourceName = element.getType();
			if (profile == null) {
				long t = System.nanoTime();
				profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName);
				sdTime = sdTime + (System.nanoTime() - t);
				ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for resource type '" + resourceName + "'");
			} else {
				String type = profile.getKind() == StructureDefinitionKind.LOGICAL ? profile.getId() : profile.hasBaseType() && profile.getDerivation() == TypeDerivationRule.CONSTRAINT ? profile.getBaseType() : profile.getName();
				// special case: we have a bundle, and the profile is not for a bundle. We'll try the first entry instead 
				if (!type.equals(resourceName) && resourceName.equals("Bundle")) {
					Element first = getFirstEntry(element);
					if (first != null && first.getType().equals(type)) {
						element = first;
						resourceName = element.getType();
						idstatus = IdStatus.OPTIONAL; // why?
					}
				}
				ok = rule(errors, IssueType.INVALID, -1, -1, stack.getLiteralPath(), type.equals(resourceName),
						"Specified profile type was '" + type + "', but found type '" + resourceName + "'");
			}
		}

		if (ok) {
			if (idstatus == IdStatus.REQUIRED && (element.getNamedChild("id") == null))
				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource requires an id, but none is present");
			else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild("id") != null))
				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource has an id, but none is allowed");
			start(errors, resource, element, profile, stack); // root is both definition and type
		}
	}
214977
public final List<DynamicValidationComponent> getMarkerSpecificValidationComponents(File inputFile,
			File rootFolder,
			DynamicValidationContext context) {
		return getSpecificValidationComponents(
				transform(inputFile, false),
				inputFile,
				rootFolder,
				context);
	}
812322
public void loadAndValidate() throws CmsConfigurationException {

        CmsModule module = CmsModuleImportExportHandler.readModuleFromImport(m_path);
        m_module = module;
        List<CmsModuleDependency> dependencies = OpenCms.getModuleManager().checkDependencies(
            module,
            CmsModuleManager.DEPENDENCY_MODE_IMPORT);
        if (!dependencies.isEmpty()) {
            StringBuffer dep = new StringBuffer(32);
            for (int i = 0; i < dependencies.size(); i++) {
                CmsModuleDependency dependency = dependencies.get(i);
                dep.append("\n - ");
                dep.append(dependency.getName());
                dep.append(" (Version: ");
                dep.append(dependency.getVersion());
                dep.append(")");
            }
            throw new CmsConfigurationException(
                org.opencms.ui.apps.Messages.get().container(
                    org.opencms.ui.apps.Messages.ERR_MODULEMANAGER_ACTION_MODULE_DEPENDENCY_2,
                    m_path,
                    new String(dep)));
        }
    }
652234
@SuppressWarnings("rawtypes")
    static String validateProductMatches(String feature, List productMatchers, File installDir, boolean installingAsset) {
        return validateProductMatches(feature, null, productMatchers, installDir, installingAsset);
    }
951900
@Override
  public ValidationReport loadProjectFlow(final Project project, final File projectDir) {
    convertYamlFiles(projectDir);
    FlowLoaderUtils.checkJobProperties(project.getId(), this.props, this.jobPropsMap, this.errors);
    return FlowLoaderUtils.generateFlowLoaderReport(this.errors);
  }
1039684
@Override
	public List<GigJavaProblem> validate(TypeDeclaration declaration,
			IType type, CompilationUnit unit, String file)
			throws JavaModelException {
		List<GigJavaProblem> problems = new ArrayList<GigJavaProblem>();
		int flags = type.getFlags();
		
		if (!Flags.isAbstract(flags)) {
			if (!Flags.isPublic(flags)) {
				GigJavaProblem problem = new GigJavaProblem(
						Severity.ERROR, "Concrete Component class must be public", file);
				ISourceRange range = type.getNameRange();
				int offset = range.getOffset();
				problem.setSourceStart(offset);
				problem.setSourceEnd(offset + range.getLength() - 1);
				problem.setSourceLineNumber(unit.getLineNumber(offset));
				problems.add(problem);
				return problems;
			}
		}
		
		return problems;
	}
1269211
public FormInputValidator directoryNotEmpty (VisValidatableTextField field, String errorMsg) {
		DirectoryContentValidator validator = new DirectoryContentValidator(errorMsg, false);
		field.addValidator(validator);
		add(field);
		return validator;
	}
332459
protected void validateModuleFile() {

        try {
            m_importFile.loadAndValidate();
            String importSite = m_importFile.getModule().getImportSite();
            if (importSite != null) {
                getSiteSelector().setEnabled(false);
                getSiteSelector().setValue(importSite);
            }
            getOkButton().setEnabled(true);
        } catch (Exception e) {
            LOG.info(e.getLocalizedMessage(), e);
            m_importFile = null;
            getOkButton().setEnabled(false);
            CmsErrorDialog.showErrorDialog(e);

        }
    }
458784
@Override
    @FFDCIgnore({ ClassNotFoundException.class })
    public void validateEjbInjection(EJB ejb, CDIArchive injectionArchive, Class<?> injectionType) throws ClassCastException, CDIException {

        Collection<CDIArchive> moduleArchives = injectionArchive.getApplication().getModuleArchives();
        String applicationName = injectionArchive.getApplication().getName();
        String moduleName = injectionArchive.getName();

        for (CDIArchive archive : moduleArchives) {
            try {

                EJBEndpoint endpoint = findEJBEndpoint(archive, ejb, injectionType, applicationName, moduleName);

                if (endpoint != null) {
                    // Found it!
                    return;
                }
            } catch (ClassNotFoundException e) {
                // Could not find the class, even though it should be in this module
                // Give up looking but don't fail validation
                return;
            } catch (ClassCastException e) {
                // Found the EJB and it's the wrong type
                // Throw on this exception to be handled by the caller
                throw e;
            }

            //TODO what happens if the endpoint is not found in any of the archives??
        }
    }
1365601
@Override
	protected void validateComponent(final List<Diagnostic> diags) {
		if (isValidDate()) {
			super.validateComponent(diags);
		} else {
			diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this));
		}
	}