Check given messages file for validity.

@throws DocumentException
if the messages file is invalid
960051
public void checkMessages(XMLFile messagesDoc) throws DocumentException {
        // Detector elements must all have a class attribute
        // and details child element.
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/Detector"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "class");
            messagesDoc.checkElement(node, "Details");
        }

        // BugPattern elements must all have type attribute
        // and ShortDescription, LongDescription, and Details
        // child elements.
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/BugPattern"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "type");
            messagesDoc.checkElement(node, "ShortDescription");
            messagesDoc.checkElement(node, "LongDescription");
            messagesDoc.checkElement(node, "Details");
        }

        // BugCode elements must contain abbrev attribute
        // and have non-empty text
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/BugCode"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "abbrev");
            messagesDoc.checkNonEmptyText(node);
        }

        // Check that all Detectors are described
        Set<String> describedDetectorsSet = messagesDoc.collectAttributes("/MessageCollection/Detector", "class");
        checkDescribed("Bug detectors not described by Detector elements", messagesDoc, declaredDetectorsSet,
                describedDetectorsSet);

        // Check that all BugCodes are described
        Set<String> describedAbbrevsSet = messagesDoc.collectAttributes("/MessageCollection/BugCode", "abbrev");
        checkDescribed("Abbreviations not described by BugCode elements", messagesDoc, declaredAbbrevsSet, describedAbbrevsSet);
    }
1312739
def check_archive_ext (archive):
    """"""
    if not archive.lower().endswith(".dms"):
        rest = archive[-4:]
        msg = "xdms(1) archive file must end with `.dms', not `%s'" % rest
        raise util.PatoolError(msg)
268309
public static void checkMessageId(int messageId, AisMessageType... messageTypes) {
		boolean found = false;
		for (AisMessageType messageType : messageTypes) {
			if (messageType.getId() == messageId)
				found = true;
		}
		if (!found) {
			StringBuffer s = new StringBuffer();
			for (AisMessageType messageType : messageTypes) {
				if (s.length() > 0)
					s.append(",");
				s.append(messageType.getId() + "");
			}
			checkArgument(found, "messageId must be in [" + s + "]  but was " + messageId);
		}
	}
1336859
function check(filename) {
  this.filename = filename && path.resolve(filename) || '';
  this.types = [];
  this.valid = null;
}
494726
private function isValidMetaFile()
	{
		if ( $this->metaFile ) return true;

		try
		{
			$this->metaFile = $this->getFileAsXML( XBRL_SEC_XML_Package::manifestFilename );
			$this->processElement( $this->metaFile->children() );
			$xbrlFilings = $this->metaFile->children('http://www.sec.gov/Archives/edgar')->xbrlFiling;
			$this->processElement( $xbrlFilings->children( XBRL_SEC_XML_Package::edgarNamespace ) );
			$xbrlFiles = $xbrlFilings->xbrlFiles;
			$this->processXBRLFiles( $xbrlFiles->children( XBRL_SEC_XML_Package::edgarNamespace ) );

			$schemaFileList = array_filter( $this->files, function( $item ) {
				return XBRL::endsWith( $item, '.xsd' );
			} );

			if ( count( $schemaFileList ) != 1 )
			{
				throw XBRL_TaxonomyPackageException::withError( "tpe:schemaFileNotFound", "The package does not contain a schema (.xsd) file" );
			}

			// $this->schemaFile = reset( $schemaFileList );
			$this->determineSchemaFile();
		}
		catch ( XBRL_TaxonomyPackageException $ex )
		{
			throw $ex;
		}
		catch ( Exception $ex )
		{
			throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", $ex->getMessage() );
		}

		return true;
	}
924071
private boolean parseAndExecute(
            Class<?> docletClass,
            String[] argv,
            Iterable<? extends JavaFileObject> fileObjects) throws IOException {
        long tm = System.currentTimeMillis();

        ListBuffer<String> javaNames = new ListBuffer<>();

        // Preprocess @file arguments
        try {
            argv = CommandLine.parse(argv);
        } catch (FileNotFoundException e) {
            messager.error(Messager.NOPOS, "main.cant.read", e.getMessage());
            exit();
        } catch (IOException e) {
            e.printStackTrace(System.err);
            exit();
        }


        fileManager = context.get(JavaFileManager.class);

        setDocletInvoker(docletClass, fileManager, argv);

        compOpts = Options.instance(context);
        // Make sure no obsolete source/target messages are reported
        compOpts.put("-Xlint:-options", "-Xlint:-options");

        // Parse arguments
        for (int i = 0 ; i < argv.length ; i++) {
            String arg = argv[i];

            ToolOption o = ToolOption.get(arg);
            if (o != null) {
                // hack: this restriction should be removed
                if (o == ToolOption.LOCALE && i > 0)
                    usageError("main.locale_first");

                try {
                    if (o.hasArg) {
                        oneArg(argv, i++);
                        o.process(this, argv[i]);
                    } else {
                        setOption(arg);
                        o.process(this);
                    }
                } catch (Option.InvalidValueException e) {
                    usageError("main.option.invalid.value", e.getMessage());
                }
            } else if (arg.equals("-XDaccessInternalAPI")) {
                // pass this hidden option down to the doclet, if it wants it
                if (docletInvoker.optionLength("-XDaccessInternalAPI") == 1) {
                    setOption(arg);
                }
            } else if (arg.startsWith("-XD")) {
                // hidden javac options
                String s = arg.substring("-XD".length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                compOpts.put(key, value);
            }
            // call doclet for its options
            // other arg starts with - is invalid
            else if (arg.startsWith("-")) {
                int optionLength;
                optionLength = docletInvoker.optionLength(arg);
                if (optionLength < 0) {
                    // error already displayed
                    exit();
                } else if (optionLength == 0) {
                    // option not found
                    usageError("main.invalid_flag", arg);
                } else {
                    // doclet added option
                    if ((i + optionLength) > argv.length) {
                        usageError("main.requires_argument", arg);
                    }
                    ListBuffer<String> args = new ListBuffer<>();
                    for (int j = 0; j < optionLength-1; ++j) {
                        args.append(argv[++i]);
                    }
                    setOption(arg, args.toList());
                }
            } else {
                javaNames.append(arg);
            }
        }

        if (fileManager == null) {
            JavacFileManager.preRegister(context);
            fileManager = context.get(JavaFileManager.class);
            if (fileManager instanceof BaseFileManager) {
                ((BaseFileManager) fileManager).autoClose = true;
            }
        }
        if (fileManager instanceof BaseFileManager) {
            ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
        }

        Arguments arguments = Arguments.instance(context);
        arguments.init(messager.programName);
        arguments.allowEmpty();
        arguments.validate();

        String platformString = compOpts.get("--release");

        if (platformString != null) {
            if (compOpts.isSet("-source")) {
                usageError("main.release.bootclasspath.conflict", "-source");
            }
            if (fileManagerOpts.containsKey(Option.BOOT_CLASS_PATH)) {
                usageError("main.release.bootclasspath.conflict", Option.BOOT_CLASS_PATH.getPrimaryName());
            }

            PlatformDescription platformDescription =
                    PlatformUtils.lookupPlatformDescription(platformString);

            if (platformDescription == null) {
                usageError("main.unsupported.release.version", platformString);
            }

            compOpts.put(Option.SOURCE, platformDescription.getSourceVersion());

            context.put(PlatformDescription.class, platformDescription);

            Collection<Path> platformCP = platformDescription.getPlatformPath();

            if (platformCP != null) {
                if (fileManager instanceof StandardJavaFileManager) {
                    StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;

                    sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
                } else {
                    usageError("main.release.not.standard.file.manager", platformString);
                }
            }
        }

        compOpts.notifyListeners();

        if (javaNames.isEmpty() && subPackages.isEmpty() && isEmpty(fileObjects)) {
            usageError("main.No_packages_or_classes_specified");
        }

        if (!docletInvoker.validOptions(options.toList())) {
            // error message already displayed
            exit();
        }

        JavadocTool comp = JavadocTool.make0(context);
        if (comp == null) return false;

        if (showAccess == null) {
            setFilter(defaultFilter);
        }

        LanguageVersion languageVersion = docletInvoker.languageVersion();
        RootDocImpl root = comp.getRootDocImpl(
                docLocale,
                encoding,
                showAccess,
                javaNames.toList(),
                options.toList(),
                fileObjects,
                breakiterator,
                subPackages.toList(),
                excludedPackages.toList(),
                docClasses,
                // legacy?
                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1,
                quiet);

        // release resources
        comp = null;

        // pass off control to the doclet
        boolean ok = root != null;
        if (ok) ok = docletInvoker.start(root);

        // We're done.
        if (compOpts.get("-verbose") != null) {
            tm = System.currentTimeMillis() - tm;
            messager.notice("main.done_in", Long.toString(tm));
        }

        return ok;
    }
813627
private function checkFileTypeIsAllowed()
	{
		if(count($this->allowedMimeTypes) > 0)
		{
			if(! in_array($this->file->getMimeType(), $this->allowedMimeTypes))
			{
				throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " has not been allowed");
			}
		}
	}
743743
protected function validateFileContents() {
		if (!$this->fileName) {
			throw new \LogicException("Missing file's path. Looks like severe internal error.");
		}
		$this->validateFilePath($this->fileName);
		if (!$this->sha1hash) {
			throw new \LogicException("Missing file's SHA1 hash. Looks like severe internal error.");
		}
		if ($this->sha1hash !== sha1_file($this->fileName)) {
			throw new IOException("The file on disk has changed and this " . get_class($this) . " class instance is no longer valid for use. Please create fresh instance.");
		}
		return true;
	}
812980
protected boolean checkSupportedMessageTypes(Message msg) {
        if (msg instanceof TextMessage) {
            return true;
        } else {
            try {
                log.error("Unsupported message type: " + msg.getJMSType());
            } catch (JMSException ignore) {
            }
            sendToInvalidMessageQueue(msg);
            return false;
        }
    }
1216456
int checkAndSendMtcToSession(Session session, JsTopicMessageController msgControl, MessageToClient mtc, Object payload) throws SessionException {
		if (session != null) {
			if (session.isOpen()) {
				try {
					if (null != msgControl) {
						checkMessageTopic(userContextFactory.getUserContext(session.getId()), mtc.getId(), payload, msgControl);
					}
					mtc.setType(MessageType.MESSAGE);
					session.getAsyncRemote().sendObject(mtc);
					return 1;
				} catch (NotRecipientException ex) {
					logger.debug("{} is exclude to receive a message in {}", ex.getMessage(), mtc.getId());
				}
			} else {
				throw new SessionException("CLOSED", null, session);
			}
		}
		return 0;
	}
751589
private List<ValidationPlanResult> validateFile(File file, Writer writer) throws IOException
	{

		List<ValidationPlanResult> messages = new ArrayList<ValidationPlanResult>();
		ArrayList<Object> entryList = new ArrayList<Object>();
		BufferedReader fileReader = null; 

		try
		{
			fileReader= new BufferedReader(new FileReader(file));
			prepareReader(	fileReader,file.getName());
			List<ValidationPlanResult> results = validateEntriesInReader(writer,file,entryList);
			ValidationPlanResult entrySetResult = validateEntry(entryList);
			if (file != null)
			{
				entrySetResult.setTargetOrigin(file.getName());
			}
			for (ValidationPlanResult planResult : results)
			{
				messages.add(planResult);
			}
			if (!entrySetResult.isValid())
			{
				writeResultsToFile(entrySetResult);
				messages.add(entrySetResult);
			}

		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally{
			if(fileReader!=null)
			fileReader.close();
		}

		return messages;
	}
296721
private static void validateEntities(org.w3c.dom.Element document, JsonNode entityJson) throws InvalidInputException,
      ProcessingException {
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xpath = xPathfactory.newXPath();

    NodeList nodes;
    try {
      XPathExpression expr = xpath.compile("//@data-entity-id");
      nodes = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
      throw new ProcessingException("Internal error processing document tree: " + e.getMessage());
    }

    for (int i = 0; i < nodes.getLength(); i++) {
      Node node = nodes.item(i);
      String entityId = ((org.w3c.dom.Attr) node).getValue();

      JsonNode entityNode = entityJson.findPath(entityId);
      if (entityNode.isMissingNode()) {
        throw new InvalidInputException("Error processing EntityJSON: "
            + "no entity data provided for \"data-entity-id\"=\"" + entityId + "\"");
      } else if (!entityNode.isObject()) {
        throw new InvalidInputException("Error processing EntityJSON: "
            + "the node \"" + entityId + "\" has to be an object");
      }
    }
  }
974998
private MessageType checkMessageInitialized(MessageType message)
      throws InvalidProtocolBufferException {
    if (message != null && !message.isInitialized()) {
      throw newUninitializedMessageException(message)
          .asInvalidProtocolBufferException()
          .setUnfinishedMessage(message);
    }
    return message;
  }
433789
def IsValidForDescriptor(self, message_descriptor):
    """"""
    for path in self.paths:
      if not _IsValidPath(message_descriptor, path):
        return False
    return True
1065507
public boolean hasNext() {
    synchronized (lock) {
      try {
        return parser.peek() != JsonToken.END_DOCUMENT;
      } catch (MalformedJsonException e) {
        throw new JsonSyntaxException(e);
      } catch (IOException e) {
        throw new JsonIOException(e);
      }
    }
  }
45171
public function validateUpdateDocument()
    {
        $this->_documentMustHavePrimaryData();
        $this->_primaryDataMustHaveType();
        $this->_primaryDataMustHaveId();
        $this->_primaryDataMayHaveRelationships();

        if ($this->_errorCollection->count() === 0) {
            return;
        }

        throw new ValidationException($this->_getErrorCollectionEntity());
    }
749273
@Override
    public boolean clearDocuments() throws DocumentException {

        File internalFolder = new File(this.getDocumentsInternalPath());
        File[] files = internalFolder.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                try {
                    FileUtils.deleteDirectory(file);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new DocumentException("Unable to delete " + file.getAbsolutePath());
                }
                log.info("Folder deleted: {}", file.getAbsolutePath());
            } else {
                boolean deleted = file.delete();
                if (deleted) {
                    log.info("File deleted: {}", file.getAbsolutePath());
                } else {
                    log.warn("Unable to delete file: {}", file.getAbsolutePath());
                }
            }
        }

        // Clear media types index
        File mapFile = new File(URI.create(new StringBuilder(documentsInternalPath.toString()).append("/" + MEDIA_TYPE_INDEX).toString()));
        if (mapFile.exists()) {
            mapFile.delete();
        }
        fileMediatypeMap.clear();

        // Generate Event
        this.getEventBus().post(new DocumentsClearedEvent(new Date()));

        return true;
    }