Validate the extension file as a GeoPackage

@param file
GeoPackage file
769312
public static void validateGeoPackageExtension(File file) {
		if (!hasGeoPackageExtension(file)) {
			throw new GeoPackageException("GeoPackage database file '" + file
					+ "' does not have a valid extension of '"
					+ GeoPackageConstants.GEOPACKAGE_EXTENSION + "' or '"
					+ GeoPackageConstants.GEOPACKAGE_EXTENDED_EXTENSION + "'");
		}
	}
115633
private File checkFile(File file) {
		final String extension = getExtension(file.getName()).toLowerCase(Locale.getDefault());
		if (!Arrays.asList(extensions).contains(extension)) {
			// En lecture, vérifie le format du fichier sélectionné.
			//			if (openOrSave) {
			//				final StringBuilder sb = new StringBuilder(
			//						"L'extension du fichier sélectionné n'est pas un format d'image accepté");
			//				sb.append(" (");
			//				for (final Iterator<String> it = Arrays.asList(extensions).iterator(); it.hasNext();) {
			//					sb.append(it.next());
			//					if (it.hasNext()) {
			//						sb.append(", ");
			//					}
			//				}
			//				sb.append(')');
			//				throw new IOException(sb.toString());
			//			}
			// si pas d'extension ou extension inconnue, on prend png par défaut
			return new File(file.getPath() + ".png");
		}

		return file;
	}
687250
public static void makeSecurityCheck( final File    file,
                                          final File    base )
    {
        if( ! file.getAbsolutePath().startsWith( base.getAbsolutePath() ) )
        {
            throw new IllegalArgumentException( "Illegal file path [" + file + "]" );
        }
    }
659455
public static void updateMetadata(final File file, final PropertyMap map, final boolean calcChecksums) throws FrameworkException {

		final java.io.File fileOnDisk = file.getFileOnDisk(false);

		if (fileOnDisk != null && fileOnDisk.exists()) {

			try {

				final PropertyKey<Long> fileModificationDateKey = StructrApp.key(File.class, "fileModificationDate");
				final PropertyKey<String> contentTypeKey        = StructrApp.key(File.class, "contentType");
				final PropertyKey<Long> sizeKey                 = StructrApp.key(File.class, "size");

				String contentType = file.getContentType();

				// Don't overwrite existing MIME type
				if (StringUtils.isBlank(contentType)) {

					try {

						contentType = getContentMimeType(file);
						map.put(contentTypeKey, contentType);

					} catch (IOException ex) {
						logger.debug("Unable to detect content MIME type", ex);
					}
				}

				map.put(fileModificationDateKey, fileOnDisk.lastModified());

				if (calcChecksums) {
					map.putAll(getChecksums(file, fileOnDisk));
				}

				if (contentType != null) {

					// modify type when image type is detected AND the type is "File"
					if (contentType.startsWith("image/") && Boolean.FALSE.equals(Image.class.isAssignableFrom(file.getClass())) && File.class.getSimpleName().equals(file.getClass().getSimpleName())) {
						map.put(AbstractNode.type, Image.class.getSimpleName());
					}
				}

				long fileSize = FileHelper.getSize(fileOnDisk);
				if (fileSize > 0) {

					map.put(sizeKey, fileSize);
				}

				file.unlockSystemPropertiesOnce();
				file.setProperties(file.getSecurityContext(), map);

			} catch (IOException ioex) {
				logger.warn("Unable to access {} on disk: {}", fileOnDisk, ioex.getMessage());
			}
		}
	}
664690
public void setFile(File file) throws IOException {
        if(!file.isFile())
            throw new IllegalArgumentException(file+" must be a file.");
        else {
            if(file.getName().endsWith("gz"))
                initGzReader(file);
            else
                initReader(file);
        }
    }
494430
public boolean fileMatchesRules(File file) {

        try {
            if(file.exists()) {
                if(includeFilesContainingText.length == 0 && excludeFilesContainingText.length == 0) {
                    return fileMatchesRules(
							getComparableFileName(file));
                } else {
                    return fileMatchesRules(
							getComparableFileName(file),
                            FileSupport.getTextFileFromFS(file));
                }
            }
        } catch (IOException ioe) {
            //at the moment file does not match rules
        }
		return false;
	}
579930
public static boolean hasExtension(File file, String... extensions) {
        String extension = FilenameUtils.getExtension(file.getName());
        for (String s : extensions) {
            if (extension.equalsIgnoreCase(s) || ("." + extension).equalsIgnoreCase(s)) {
                return true;
            }
        }
        return false;
    }
284782
public static String extension(String file) {
      if (StringUtils.isNullOrBlank(file)) {
         return StringUtils.EMPTY;
      }
      file = StringUtils.trim(file);
      int index = indexOfFileExtension(file);
      if (index == -1) {
         return StringUtils.EMPTY;
      }
      return file.substring(index + 1);
   }
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" );
    }
834257
private void validateRangeValue(String column, Object value) {
		if (constraintType != null && value != null
				&& !getConstraintType().equals(DataColumnConstraintType.RANGE)) {
			throw new GeoPackageException("The " + column
					+ " must be null for " + DataColumnConstraintType.ENUM
					+ " and " + DataColumnConstraintType.GLOB + " constraints");
		}
	}
1058222
@Pure
	public static boolean isShapeFile(URL file) {
		return FileType.isContentType(
				file,
				MimeName.MIME_SHAPE_FILE.getMimeConstant());
	}
1124116
public static String getExtension(File file)
    {
        Check.notNull(file);

        return getExtension(file.getName());
    }
1257368
public T addPropertiesFile(final String file) {
        if (file != null) {
            addPropertiesFile(Paths.get(file));
        }
        return getThis();
    }
269250
public static void checkValidFile(final File file) {
        checkNotNull("file", file);
        if (!file.exists()) {
            throw new IllegalArgumentException("The file '" + file + "' does not exist!");
        }
        if (!file.isFile()) {
            throw new IllegalArgumentException("The name '" + file + "' is not a file!");
        }
    }
464586
private GeoPackage getOrOpen(String name, File file, boolean cache) {
		GeoPackage geoPackage = get(name);
		if (geoPackage == null) {
			geoPackage = GeoPackageManager.open(name, file);
			if (cache) {
				add(geoPackage);
			}
		}
		return geoPackage;
	}
127935
public void load() {
		properties = new Properties();

		try {
			InputStream in = new FileInputStream(propertiesFile);

			try {
				properties.load(in);
			} catch (Exception e) {
				throw new GeoPackageException(
						"Failed to load properties file for GeoPackage file format located at: "
								+ propertiesFile, e);
			} finally {
				try {
					in.close();
				} catch (IOException e) {
					LOGGER.log(Level.WARNING,
							"Failed to close properties file: "
									+ propertiesFile, e);
				}
			}
		} catch (FileNotFoundException e) {
			throw new GeoPackageException(
					"GeoPackage file format requires a properties file located at: "
							+ propertiesFile, e);
		}
	}
1164224
public T addPropertiesFile(final Path file) {
        if (file != null) {
            if (Files.notExists(file)) {
                throw LauncherMessages.MESSAGES.pathDoesNotExist(file);
            }
            if (!Files.isRegularFile(file)) {
                throw LauncherMessages.MESSAGES.pathNotAFile(file);
            }
            addServerArg("-P", file.toAbsolutePath().normalize().toString());
        }
        return getThis();
    }