@Override public void loadAS5Data(MigrationContext ctx) throws LoadMigrationException { // TBC: Maybe use FileUtils and list all files with that name? File file = Utils.createPath( super.getGlobalConfig().getAS5Config().getDir(), "server", super.getGlobalConfig().getAS5Config().getProfileName(), "deploy", "jbossweb.sar", "server.xml"); if (!file.canRead()) throw new LoadMigrationException( "Cannot find/open file: " + file.getAbsolutePath(), new FileNotFoundException()); try { Unmarshaller unmarshaller = JAXBContext.newInstance(ServerAS5Bean.class).createUnmarshaller(); ServerAS5Bean serverAS5 = (ServerAS5Bean) unmarshaller.unmarshal(file); MigrationData mData = new MigrationData(); for (ServiceBean s : serverAS5.getServices()) { mData.getConfigFragments().add(s.getEngine()); mData.getConfigFragments().addAll(s.getConnectorAS5s()); } ctx.getMigrationData().put(ServerMigrator.class, mData); } catch (JAXBException e) { throw new LoadMigrationException("Failed parsing logging config file: " + file.getPath(), e); } }
@Override public void createActions(MigrationContext ctx) throws MigrationException { ServerMigratorResource resource = new ServerMigratorResource(); try { createDefaultSockets(ctx, resource); } catch (LoadMigrationException e) { throw new MigrationException("Migration of web server failed: " + e.getMessage(), e); } for (IConfigFragment fragment : ctx.getMigrationData().get(ServerMigrator.class).getConfigFragments()) { String what = null; try { if (fragment instanceof ConnectorAS5Bean) { what = "connector"; ctx.getActions() .addAll( createConnectorCliAction( migrateConnector((ConnectorAS5Bean) fragment, resource, ctx))); } else if (fragment instanceof EngineBean) { what = "Engine (virtual-server)"; ctx.getActions().add(createVirtualServerCliAction(migrateEngine((EngineBean) fragment))); } else throw new MigrationException( "Config fragment unrecognized by " + this.getClass().getSimpleName() + ": " + fragment); } catch (CliScriptException | NodeGenerationException e) { throw new MigrationException("Migration of the " + what + " failed: " + e.getMessage(), e); } } for (SocketBindingBean sb : resource.getSocketBindings()) { try { ctx.getActions().add(createSocketBindingCliAction(sb)); } catch (CliScriptException e) { throw new MigrationException( "Creation of the new socket-binding failed: " + e.getMessage(), e); } } }