Addendum to r183
git-svn-id: https://svn.libreccm.org/ccm/trunk@177 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
7b1ffd0422
commit
eedb8474e4
|
|
@ -21,6 +21,7 @@ package com.arsdigita.packaging;
|
|||
import com.arsdigita.runtime.ConfigRegistry;
|
||||
import com.arsdigita.util.Files;
|
||||
import com.arsdigita.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
|
@ -30,19 +31,25 @@ import java.util.List;
|
|||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Implements the "hostinit" command.
|
||||
*
|
||||
* Called by the ccm hostinit / ccm hostinit-bundle command
|
||||
*
|
||||
* Populates the CCM application directory in webapps.
|
||||
*
|
||||
* Implements the "hostinit" command and is called by the
|
||||
* ccm hostinit / ccm hostinit-bundle command of the ccm PERL based
|
||||
* script system (up to APLAWS 1.0.5 / CCM 6.5).
|
||||
*
|
||||
* In addition to populating the webapp directory the ccm command
|
||||
* used to configure the servlet container (hence to information
|
||||
* about servlet container and http port below).
|
||||
* Does not create the database nor the config registry.
|
||||
*
|
||||
* Options:
|
||||
|
|
@ -110,6 +117,7 @@ public class HostInit {
|
|||
}
|
||||
|
||||
public static final void main(String[] args) {
|
||||
|
||||
if (args.length == 0) {
|
||||
Command.usage(OPTIONS, System.err,
|
||||
"com.arsdigita.packaging.HostInit", null);
|
||||
|
|
@ -117,7 +125,8 @@ public class HostInit {
|
|||
}
|
||||
|
||||
// Register custom protocol handlers
|
||||
com.arsdigita.runtime.Startup.startup();
|
||||
// No longer needed as of CCM 6.6
|
||||
// com.arsdigita.runtime.Startup.startup();
|
||||
|
||||
CommandLine line;
|
||||
try {
|
||||
|
|
@ -135,12 +144,16 @@ public class HostInit {
|
|||
// base dir for all webapps, same as CATALINA_HOME
|
||||
// same as CCM_HOME
|
||||
File dest = new File(destination);
|
||||
|
||||
// Currently: non-standard location of lib and classes
|
||||
File inf = new File(dest, "WEB-INF");
|
||||
|
||||
// Currentliy: non-standard location of lib
|
||||
File lib = new File(inf, "lib");
|
||||
// currently: non-standard, special URL:resource handler, to be discarded
|
||||
File system = new File(inf, "system");
|
||||
|
||||
// currently (<=6.5): non-standard, special URL:resource handler, to be discarded
|
||||
// Removed on >= 6.6
|
||||
// File system = new File(inf, "system");
|
||||
|
||||
if (!dest.exists()) {
|
||||
dest.mkdir();
|
||||
|
|
@ -164,18 +177,21 @@ public class HostInit {
|
|||
err("unable to create lib: " + lib);
|
||||
}
|
||||
|
||||
system.mkdirs();
|
||||
if (!(system.exists() && system.isDirectory())) {
|
||||
err("unable to create system: " + system);
|
||||
}
|
||||
// >= 6.6 system jar removed
|
||||
// system.mkdirs();
|
||||
// if (!(system.exists() && system.isDirectory())) {
|
||||
// err("unable to create system: " + system);
|
||||
// }
|
||||
|
||||
// check the configuration database (registry) for packages (modules)
|
||||
// retrieve a list of packages to deal with
|
||||
ConfigRegistry reg = new ConfigRegistry();
|
||||
List packages = reg.getPackages();
|
||||
// Do the real work now.
|
||||
try {
|
||||
copy(classpath, packages, lib);
|
||||
copySystem(classpath, packages, system);
|
||||
// no longer used >= 6.6
|
||||
// copySystem(classpath, packages, system);
|
||||
copy(webapps, packages, dest);
|
||||
} catch (IOException e) {
|
||||
err(e.getMessage());
|
||||
|
|
@ -183,10 +199,12 @@ public class HostInit {
|
|||
}
|
||||
|
||||
/**
|
||||
* Internal general helper method to copy files from one location to a
|
||||
* destination dir using a list of files (packages) to copy.
|
||||
*
|
||||
* @param pathfile
|
||||
* @param packages
|
||||
* @param dest
|
||||
* @param pathfile Path where to look for files specified in packages
|
||||
* @param packages List of files to copy
|
||||
* @param dest Destination directory
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
private static void copy(String pathfile, List packages, File dest)
|
||||
|
|
@ -226,45 +244,11 @@ public class HostInit {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copies the ccm-core-6.y.z-system.jar (java extension for URL:resource
|
||||
* protocol handler) to its special location.
|
||||
* Internal helper method to copy all files in a given directory (dir)
|
||||
* to a destination directory (dest).
|
||||
*
|
||||
* Will not be used as soon as the resource protocol is replaced by a
|
||||
* standard compliant mechanism.
|
||||
*
|
||||
* @param pathfile
|
||||
* @param packages
|
||||
* @param dest
|
||||
* @throws java.io.IOException
|
||||
* @deprecated
|
||||
*/
|
||||
private static void copySystem(String pathfile, List packages, File dest)
|
||||
throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(pathfile));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (contains(line, packages) && line.endsWith(".jar")) {
|
||||
String newline = line.substring(0, line.lastIndexOf(".jar")) +
|
||||
"-system.jar";
|
||||
File file = new File(newline);
|
||||
if (file.isFile()) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Copying System JAR " + file.toString());
|
||||
}
|
||||
Files.copy(file, dest, Files.IGNORE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all files in a given directory (dir) to a
|
||||
* destination directory (dest).
|
||||
*
|
||||
* @param dir
|
||||
* @param dest
|
||||
* @param dir source directory path
|
||||
* @param dest destination direcotry path
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
private static void copyDirectory(File dir, File dest) throws IOException {
|
||||
|
|
@ -321,6 +305,9 @@ public class HostInit {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static boolean contains(String line, List packages) {
|
||||
for (Iterator it = packages.iterator(); it.hasNext(); ) {
|
||||
String key = (String) it.next();
|
||||
|
|
@ -331,4 +318,40 @@ public class HostInit {
|
|||
return false;
|
||||
}
|
||||
|
||||
// As of version 6.6 system.jar is no longer used. Code kept here as
|
||||
// an example just in case the mechanism is required for another purpose.
|
||||
// /**
|
||||
// * Copies the ccm-core-6.y.z-system.jar (java extension for URL:resource
|
||||
// * protocol handler) to its special location.
|
||||
// *
|
||||
// * Will not be used as soon as the resource protocol is replaced by a
|
||||
// * standard compliant mechanism.
|
||||
// *
|
||||
// * @param pathfile
|
||||
// * @param packages
|
||||
// * @param dest
|
||||
// * @throws java.io.IOException
|
||||
// * @deprecated
|
||||
// */
|
||||
// private static void copySystem(String pathfile, List packages, File dest)
|
||||
// throws IOException {
|
||||
// BufferedReader reader = new BufferedReader(new FileReader(pathfile));
|
||||
// String line;
|
||||
// while ((line = reader.readLine()) != null) {
|
||||
// line = line.trim();
|
||||
// if (contains(line, packages) && line.endsWith(".jar")) {
|
||||
// String newline = line.substring(0, line.lastIndexOf(".jar")) +
|
||||
// "-system.jar";
|
||||
// File file = new File(newline);
|
||||
// if (file.isFile()) {
|
||||
// if (s_log.isInfoEnabled()) {
|
||||
// s_log.info("Copying System JAR " + file.toString());
|
||||
// }
|
||||
// Files.copy(file, dest, Files.IGNORE_EXISTING);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// reader.close();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue