dev@glassfish.java.net

Re: copy file utility in GFLauncher?

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Fri, 10 Dec 2010 11:27:41 -0500

Since I didn't see this email show up here for a while, I asked again on an internal alias. Here's what I take the consensus to be from that thread:

The utility code question: FileUtils.copy(File fin, File fout) in common/common-utils module.

How should I create my source file object? Using the File constructors.

Thanks all for the suggestions.

Cheers,
Bobby

On Dec 9, 2010, at 2:35 PM, Bobby Bissett wrote:

> To fix http://java.net/jira/browse/GLASSFISH-11665. I've added a method to GFLauncher to check the jvm options and upgrade flag like so:
>
> private void setupUpgradeSecurity() {
> // If this is an upgrade and the security manager is on,
> // copy the current server.policy file to the domain
> // before the upgrade.
> if (info.isUpgrade() &&
> jvmOptions.sysProps.containsKey("java.security.manager")) {
>
> File source = // <info.installDir>/lib/templates/server.policy
> File target = new File(info.getConfigDir(), "server.policy");
>
> }
> }
>
> Is there some utility code already written that I can call to copy source to target above?
>
>
> Bonus question: anyone have a preference as to whether the path for 'source' above is created with a string of StringBuilder appends (info.installDir's path, File.separator, 'lib', File.separator, etc.) or the concise but for-all-I-know wasteful new File(new File(new File(info.installDir, "lib"), "templates"), "server.policy")? Or maybe we even have a utility method for this somewhere that takes a file and string array?
>
>
> The intent of the above is to copy the 3.1 policy to the domain. I could try to use it *only* during the upgrade and not at runtime (-Djava.security.policy), or simply turn off the security manager during the upgrade and leave it alone, but I see doing that results in a 3.1 installation with an old policy, and then the server won't start.
>
> Thanks,
> Bobby
>