@Override public final void runBare() throws Throwable { // Patch a bug with maven that does not pass properly the system property // with an empty value if ("org.hsqldb.jdbcDriver".equals(System.getProperty("gatein.test.datasource.driver"))) { System.setProperty("gatein.test.datasource.password", ""); } // log.info("Running unit test:" + getName()); for (Map.Entry<?, ?> entry : System.getProperties().entrySet()) { if (entry.getKey() instanceof String) { String key = (String) entry.getKey(); log.debug(key + "=" + entry.getValue()); } } // beforeRunBare(); // try { super.runBare(); log.info("Unit test " + getName() + " completed"); } catch (Throwable throwable) { log.error("Unit test " + getName() + " did not complete", throwable); // throw throwable; } finally { afterRunBare(); } }
/** * The onInit() method is used to prepare the portal to receive requests. * * <p>1) Get the WebAppController component from the container 2) Create a new PortalApplication, * init it with the ServletConfig object (which contains init params) 3) Register that * PortalApplication inside WebAppController 4) Create a new PortalRequestHandler object and * register it in the WebAppController */ private void onInit(ServletConfig sConfig, PortalContainer portalContainer) { // Keep the old ClassLoader final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); boolean hasChanged = false; try { ServletConfig config = new PortalServletConfig(sConfig, portalContainer); WebAppController controller = (WebAppController) portalContainer.getComponentInstanceOfType(WebAppController.class); // Set the full classloader of the portal container Thread.currentThread().setContextClassLoader(portalContainer.getPortalClassLoader()); hasChanged = true; controller.onHandlersInit(config); log.info( "The WebAppController has been successfully initialized for the portal '" + portalContainer.getName() + "'"); } catch (Throwable t) { log.error( "The WebAppController could not be initialized for the portal '" + portalContainer.getName() + "'", t); } finally { if (hasChanged) { // Re-set the old classloader Thread.currentThread().setContextClassLoader(currentClassLoader); } } }
static { // Detecting version from maven properties // empty value is ok String version = ""; URL url = ResourceRequestHandler.class.getClassLoader().getResource(PATH); if (url != null) { log.debug("Loading resource serving version from " + url); InputStream in = null; try { in = url.openStream(); Properties props = new Properties(); props.load(in); version = props.getProperty("version"); } catch (IOException e) { log.error("Could not read properties from " + url, e); } finally { IOTools.safeClose(in); } } // log.info("Use version \"" + version + "\" for resource serving"); VERSION = version; }
public void doImport() { if (portalContainer == null) { portalContainer = Utils.getUserInput("Container name (ie portal)", level); } try { client = PortalObjectsMgmtClient.Factory.create( InetAddress.getByName(host), port, username, password, portalContainer); } catch (UnknownHostException e) { System.err.println("Unknown host name " + host + ". See log for more details."); log.error("Exception retrieving host " + host + " by name.", e); System.exit(1); } if (overwrite == null) { String ow = Utils.getUserInput( "Do you wish to fully overwrite all data defined in import file (N) ? Y/N", level); if ("Y".equalsIgnoreCase(ow)) { overwrite = Boolean.TRUE; } else { overwrite = Boolean.FALSE; } } if (overwrite && !force) { System.out.println( "\nOverwrite set to true. This means that all data for a site will be overwritten and any data not defined will be deleted."); String proceed = Utils.getUserInput("Do you wish to proceed (N) ? Y/N", level); if (!"Y".equalsIgnoreCase(proceed)) { System.exit(0); } } log.info("Starting import of file " + importFile + " for portal container " + portalContainer); try { ImportContext context = client.importFromZip(importFile); if (isEmptyContext(context)) { System.out.println( "Nothing to import. " + importFile + " did not contain anything to import."); log.warn("Nothing imported. Zip file did not contain any data for import."); System.exit(0); } if (overwrite) { log.info("Overwrite set to true, overwriting all data."); } context.setOverwrite(overwrite); client.importContext(context); log.info("Import was successful."); } catch (IOException e) { System.err.println("Exception reading zip file. See log for more details."); log.error("IOException reading zip file " + importFile, e); } catch (ClientException e) { System.err.println("Client exception during import. See log for more details."); log.error("ClientException during import.", e); } catch (Throwable t) { System.err.println("Unknown exception occurred during import. See log for more details."); log.error("Uknown exception during import.", t); } }