Checks if FileDataSource is correctly connected. In case that the
contract is incorrectly connected a RuntimeException is thrown.

@param fileSource
FileDataSource that is checked.
762417
private void checkFileDataSource(FileDataSourceBase<?> fileSource) {
		String path = fileSource.getFilePath();
		if (path == null) {
			throw new InvalidProgramException("File path of FileDataSource is null.");
		}
		if (path.length() == 0) {
			throw new InvalidProgramException("File path of FileDataSource is empty string.");
		}
		
		try {
			Path p = new Path(path);
			String scheme = p.toUri().getScheme();
			
			if (scheme == null) {
				throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource has no file system scheme (like 'file:// or hdfs://').");
			}
		} catch (Exception e) {
			throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource is an invalid path: " + e.getMessage());
		}
	}
1339561
public function checkConnection( $checkResource = TRUE, $checkAuthentication = TRUE )
	{
		if( $checkResource && !$this->resource )
			throw new RuntimeException( "No Connection to FTP Server established" );
		if( $checkAuthentication && !$this->auth )
			throw new RuntimeException( "Not authenticated onto FTP Server" );
	}
294901
@Override
    public void checkRepositoryStatus() throws IOException {
        if (!exists(null)) {
            throw new FileNotFoundException("Could not find " + _root);
        }
        if (!hasChildren(null)) {
            throw new IOException("The root (" + _root + " is not a directory ");
        }
    }
750267
@Override
    public boolean fileCreated(File file) throws WatchingException {
        try {
            createApplicationBundle();
        } catch (Exception e) {
            throw new WatchingException(e.getMessage(), file, e);
        }
        return true;
    }
178218
private void addLinkedResource(FilePathMapping linkedResource) {
		linkedResources.add(linkedResource);
		if (parent != null) {
			parent.addLinkedResource(linkedResource);
		}
	}
1157662
public void addSourcePath(File sourcePath) {
		if (this.sourcePath == null) {
			this.sourcePath = new ArrayList<>();
		}
		this.sourcePath.add(sourcePath);
	}
484534
public void setDataSources(java.util.Collection<DataSource> dataSources) {
        if (dataSources == null) {
            this.dataSources = null;
            return;
        }

        this.dataSources = new com.amazonaws.internal.SdkInternalList<DataSource>(dataSources);
    }
104426
protected void checkCobolSourceFile(final File cobolSourceFile)
            throws IOException {
        if (cobolSourceFile == null) {
            throw new IOException("You must provide a COBOL source file");
        }
        if (!cobolSourceFile.exists()) {
            throw new IOException("COBOL source  file " + cobolSourceFile
                    + " not found");
        }
    }
1215492
@LogExecTime
	public void verifyImageSource(String locator, String src)
	{
		jtImage.verifyImageSource(locator, src);
	}
408858
@Override
    public void saveSourceToFile(Source source) {
        Origin origin = source.getOrigin();
        if (!(origin instanceof FileOrigin)) {
            throw new IllegalArgumentException("No a file origin: " + origin);
        }

        File file = ((FileOrigin) origin).getFile();
        File dir = file.getParentFile();
        if (!dir.exists()) {
            dir.mkdirs();
        } else {
            if (!dir.isDirectory()) {
                throw new RuntimeException("Can not save file, '" + dir + "' is not a valid directory.");
            }
        }
        List<String> lines = new ArrayList<String>();
        lines.add(Source.TRIPLE_DASHED_LINE);
        //for(Map.Entry<String, Object> en: source.getMeta().entrySet()){
        //
        //}
        String line = yaml.dumpAsMap(source.getMeta());
        lines.add(line);
        lines.add(Source.TRIPLE_DASHED_LINE);

        lines.add(source.getContent());

        try {
            FileUtils.writeLines(file, "UTF-8", lines);
        } catch (IOException e) {
            throw new RuntimeException("Write file exception", e);
        }
    }
1303813
public static void updateFileFromFile(final File sourceFile, final String destinationFilePath) throws
        UpdateException {
        if (!sourceFile.exists()) {
            throw new UpdateException("Source file does not exist: " + sourceFile);
        }
        if (!sourceFile.isFile()) {
            throw new UpdateException("Not a file: " + sourceFile);
        }
        if (sourceFile.length() < 1) {
            throw new UpdateException("Source file is empty: " + sourceFile);
        }

        try {
            updateFileFromInputStream(new FileInputStream(sourceFile), destinationFilePath);
        } catch (IOException e) {
            throw new UpdateException("Unable to update file: " + e.getMessage(), e);
        }
    }
118913
public void addDataSource(int groupno, DataSource datasource) {
    // the loader takes care of validation
    if (groupno == 0)
      datasources.add(datasource);
    else if (groupno == 1)
      group1.add(datasource);
    else if (groupno == 2)
      group2.add(datasource);
  }
1097512
private static boolean isFile(Node node) throws RepositoryException
   {
      if (!node.isNodeType("nt:file"))
      {
         return false;
      }
      if (!node.getNode("jcr:content").isNodeType("nt:resource"))
      {
         return false;
      }
      return true;
   }
56816
private void loadFileSources(final File directory, final String project) {
        //clear source sequence

        if (!directory.isDirectory()) {
            logger.warn("Not a directory: " + directory);
        }
        //get supported parser extensions
        final Set<String> exts = new HashSet<String>(
            framework.getResourceFormatParserService().listSupportedFileExtensions());
        final File[] files = directory.listFiles(new FilenameFilter() {
            public boolean accept(final File file, final String s) {
                return exts.contains(
                    ResourceFormatParserService.getFileExtension(s));
            }
        });

        //set of previously cached file sources by file
        if (null != files) {
            //sort on filename
            Arrays.sort(files, null);
            synchronized (sourceCache) {
                final HashSet<File> trackedFiles = new HashSet<File>(sourceCache.keySet());
                for (final File file : files) {
                    //remove file that we want to keep
                    trackedFiles.remove(file);
                    if (!sourceCache.containsKey(file)) {
                        logger.debug("Adding new resources file to cache: " + file.getAbsolutePath());
                        try {
                            final ResourceModelSource source = createFileSource(project, file);
                            sourceCache.put(file, source);

                        } catch (ExecutionServiceException e) {
                            e.printStackTrace();
                            logger.debug("Failed adding file " + file.getAbsolutePath() + ": " + e.getMessage(), e);
                        }
                    }
                }
                //remaining trackedFiles are files that have been removed from the dir
                for (final File oldFile : trackedFiles) {
                    logger.debug("Removing from cache: " + oldFile.getAbsolutePath());
                    sourceCache.remove(oldFile);
                }
            }
        }
    }
173197
public void addAttachment(final String name, final DataSource filedata) {
		attachments.add(new AttachmentResource(name, filedata));
	}
1320945
public boolean isValidFileToCopy(File projectDir, File src, Set<String> ignoreFileSet) throws IOException {
        if (isValidSourceFileOrDir(src)) {
            if (src.equals(projectDir)) {
                return true;
            }
            String relative = relativePath(projectDir, src);
            return !sourceCodeDirPaths.contains(relative) && !ignoreFileSet.contains(relative);
        }
        return false;
    }
71405
public SourceFile getSourceFile(File file) throws IOException
	{
		SourceFile source = sourceFiles.get(file);

		if (source == null)
		{
			source = new SourceFile(file);
			sourceFiles.put(file, source);
		}

		return source;
	}