MCPcopy Index your code
hub / github.com/apache/tomcat / migrateLegacyApp

Method migrateLegacyApp

java/org/apache/catalina/startup/HostConfig.java:1196–1232  ·  view source on GitHub ↗

Migrate a single legacy Java EE application from source to destination using the Migration utility. @param source the source file @param destination the destination file

(File source, File destination)

Source from the content-addressed store, hash-verified

1194 * @param destination the destination file
1195 */
1196 protected void migrateLegacyApp(File source, File destination) {
1197 File tempNew = null;
1198 File tempOld;
1199 try {
1200 tempNew = File.createTempFile("new", null, host.getLegacyAppBaseFile());
1201 tempOld = File.createTempFile("old", null, host.getLegacyAppBaseFile());
1202 // createTempFile is not directly compatible with directories, so cleanup
1203 Files.delete(tempNew.toPath());
1204 Files.delete(tempOld.toPath());
1205
1206 // The use of defaults is deliberate here to avoid having to
1207 // recreate every configuration option on the host. Better to change
1208 // the defaults if necessary than to start adding configuration
1209 // options. Users that need non-default options can convert manually
1210 // via migration.[sh|bat]
1211 Migration migration = new Migration();
1212 migration.setSource(source);
1213 migration.setDestination(tempNew);
1214 migration.execute();
1215
1216 // Use rename
1217 if (destination.exists()) {
1218 Files.move(destination.toPath(), tempOld.toPath());
1219 }
1220 Files.move(tempNew.toPath(), destination.toPath());
1221 // Only delete the previous webapp if everything went fine
1222 ExpandWar.delete(tempOld);
1223
1224 } catch (Throwable t) {
1225 ExceptionUtils.handleThrowable(t);
1226 log.warn(sm.getString("hostConfig.migrateError"), t);
1227 } finally {
1228 if (tempNew != null && tempNew.exists()) {
1229 ExpandWar.delete(tempNew);
1230 }
1231 }
1232 }
1233
1234
1235 /**

Callers 1

runMethod · 0.80

Calls 11

deleteMethod · 0.95
handleThrowableMethod · 0.95
setDestinationMethod · 0.80
moveMethod · 0.80
getLegacyAppBaseFileMethod · 0.65
deleteMethod · 0.65
executeMethod · 0.65
existsMethod · 0.65
warnMethod · 0.65
getStringMethod · 0.65
setSourceMethod · 0.45

Tested by

no test coverage detected