| | |
| | | */ |
| | | public class LicenseFile { |
| | | |
| | | /** |
| | | * Get the directory in which legal files are stored. |
| | | */ |
| | | private static String getLegalDirectory() |
| | | { |
| | | if (Utils.isWebStart()) |
| | | { |
| | | return File.separatorChar + "Legal"; |
| | | } |
| | | else |
| | | { |
| | | String installRootFromSystem = System.getProperty("INSTALL_ROOT"); |
| | | |
| | | if (installRootFromSystem == null) |
| | | { |
| | | installRootFromSystem = System.getenv("INSTALL_ROOT"); |
| | | } |
| | | |
| | | if (installRootFromSystem == null) |
| | | { |
| | | installRootFromSystem = ""; |
| | | } |
| | | |
| | | return installRootFromSystem + File.separatorChar + "Legal"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the directory in which legal files are stored. |
| | | */ |
| | | private static String getInstanceLegalDirectory() |
| | | { |
| | | String instanceLegalDirName; |
| | | if (Utils.isWebStart()) |
| | | { |
| | | instanceLegalDirName = File.separatorChar + "Legal"; |
| | | } |
| | | else |
| | | { |
| | | String installDirName = System.getProperty("INSTALL_ROOT"); |
| | | |
| | | if (installDirName == null) |
| | | { |
| | | installDirName = System.getenv("INSTALL_ROOT"); |
| | | } |
| | | |
| | | if (installDirName == null) |
| | | { |
| | | installDirName = "."; |
| | | } |
| | | |
| | | String instanceDirname = Utils |
| | | .getInstancePathFromClasspath(installDirName); |
| | | instanceLegalDirName = instanceDirname + File.separator + "Legal"; |
| | | File instanceLegalDir = new File(instanceLegalDirName); |
| | | if (!instanceLegalDir.exists()) |
| | | { |
| | | instanceLegalDir.mkdir(); |
| | | } |
| | | } |
| | | return instanceLegalDirName ; |
| | | } |
| | | |
| | | /** |
| | | * The File object related to the license file. |
| | |
| | | */ |
| | | static private String getName() |
| | | { |
| | | if (Utils.isWebStart()) |
| | | { |
| | | return |
| | | File.separatorChar + |
| | | "Legal" + |
| | | File.separatorChar + |
| | | "license_to_accept.txt"; |
| | | } |
| | | else |
| | | { |
| | | |
| | | String installRootFromSystem = System.getProperty("INSTALL_ROOT"); |
| | | |
| | | if (installRootFromSystem == null) { |
| | | installRootFromSystem = System.getenv("INSTALL_ROOT"); |
| | | } |
| | | |
| | | if (installRootFromSystem == null) { |
| | | installRootFromSystem = ""; |
| | | } |
| | | |
| | | return installRootFromSystem + |
| | | File.separatorChar + |
| | | "Legal" + |
| | | File.separatorChar + |
| | | "license_to_accept.txt"; |
| | | } |
| | | return getLegalDirectory() + File.separatorChar + "license_to_accept.txt"; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | approved = p_approved; |
| | | } |
| | | |
| | | /** |
| | | * Create a file which indicates that the license has been approved. |
| | | */ |
| | | static public void createFileLicenseApproved() |
| | | { |
| | | if ( getApproval() ) |
| | | { |
| | | try |
| | | { |
| | | new File(getInstanceLegalDirectory() + File.separatorChar |
| | | + "licenseAccepted").createNewFile(); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Indicate if the license had already been approved.. |
| | | * @return <CODE>true</CODE> if the license had already been approved |
| | | * by the user <CODE>false</CODE> otherwise. |
| | | */ |
| | | static public boolean isAlreadyApproved() |
| | | { |
| | | File f = new File(getInstanceLegalDirectory() + File.separatorChar |
| | | + "licenseAccepted"); |
| | | return f.exists(); |
| | | } |
| | | |
| | | } |