From 2ea524325b5cbd5ff13afb69724784d1e18e1fdb Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 9 Apr 2012 08:18:33 -0700 Subject: [PATCH] Dimension service tests now passing again. --- .../jaxrs/CSpaceResteasyBootstrap.java | 29 ++++---- ...CollectionSpaceServiceContextListener.java | 51 +++++++++++++- .../services/common/ServiceMain.java | 67 ++++++++++++++----- .../AuthorizationCommon.java | 2 +- 4 files changed, 119 insertions(+), 30 deletions(-) diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java index d5f022be5..1a84953fb 100644 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java @@ -5,22 +5,25 @@ import javax.servlet.ServletContextEvent; import org.jboss.resteasy.core.Dispatcher; import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap; import org.collectionspace.services.common.ResourceMap; -import org.collectionspace.services.common.ServiceMain; public class CSpaceResteasyBootstrap extends ResteasyBootstrap { - public void contextInitialized(ServletContextEvent event) { - // - // This call to super instantiates and initializes our JAX-RS application class. - // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication. - // - System.out.println("[INFO] Starting up the CollectionSpace Services' JAX-RS application."); - super.contextInitialized(event); - CollectionSpaceJaxRsApplication app = - (CollectionSpaceJaxRsApplication)deployment.getApplication(); - Dispatcher disp = deployment.getDispatcher(); - disp.getDefaultContextObjects().put(ResourceMap.class, app.getResourceMap()); - System.out.println("[INFO] CollectionSpace Services' JAX-RS application started."); + public void contextInitialized(ServletContextEvent event) { + try { + // + // This call to super instantiates and initializes our JAX-RS application class. + // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication. + // + System.out.println("[INFO] Starting up the CollectionSpace Services' JAX-RS application."); + super.contextInitialized(event); + CollectionSpaceJaxRsApplication app = + (CollectionSpaceJaxRsApplication)deployment.getApplication(); + Dispatcher disp = deployment.getDispatcher(); + disp.getDefaultContextObjects().put(ResourceMap.class, app.getResourceMap()); + System.out.println("[INFO] CollectionSpace Services' JAX-RS application started."); + } catch (Throwable e) { + e.printStackTrace(); + } } @Override diff --git a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java index b2ae6814c..f7c0c251e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java +++ b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java @@ -21,14 +21,63 @@ public class CollectionSpaceServiceContextListener implements ServletContextList // ServletContext servletContext = event.getServletContext(); ServiceMain svcMain = ServiceMain.getInstance(servletContext); + + { + System.out.print("About to retrieveAllWorkspaceIds - Pausing 4:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + svcMain.retrieveAllWorkspaceIds(); + { + System.out.print("About to firePostInitHandlers - Pausing 5:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + // // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db. // Typically, these handlers modify column types and add indexes to the Nuxeo db schema. // svcMain.firePostInitHandlers(); + { + System.out.print("Finished to firePostInitHandlers - Pausing 6:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + } catch (Exception e) { e.printStackTrace(); //fail here @@ -39,6 +88,6 @@ public class CollectionSpaceServiceContextListener implements ServletContextList @Override public void contextDestroyed(ServletContextEvent event) { - ServiceMain.getInstance().release(); + //ServiceMain.getInstance().release(); } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index 0bf0add2d..2634d46ab 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -101,6 +101,23 @@ public class ServiceMain { try { //assume the worse initFailed = true; + + { + System.out.print("About to init ServiceMain - Pausing 3:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + temp.initialize(); //celebrate success initFailed = false; @@ -125,21 +142,6 @@ public class ServiceMain { } private void initialize() throws Exception { - if (logger.isTraceEnabled() == true) { - System.out.print("Pausing 5 seconds for you to attached the debugger"); - long startTime, currentTime; - currentTime = startTime = System.currentTimeMillis(); - long stopTime = startTime + 5 * 1000; //5 seconds - do { - if (currentTime % 1000 == 0) { - System.out.print("."); - } - currentTime = System.currentTimeMillis(); - } while (currentTime < stopTime); - - System.out.println(); - System.out.println("Resuming cspace services initialization."); - } setDataSources(); setServerRootDir(); @@ -150,10 +152,45 @@ public class ServiceMain { // try { AuthorizationCommon.createDefaultPermissions(tenantBindingConfigReader); + + if (logger.isDebugEnabled() == true) { + System.out.print("Pausing 1:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + AuthorizationCommon.createDefaultAccounts(tenantBindingConfigReader); + } catch(Exception e) { logger.error("Default accounts setup failed with exception(s): " + e.getLocalizedMessage()); } + + if (logger.isDebugEnabled() == true) { + System.out.print("Pausing 2:5 seconds for you to attached the debugger"); + long startTime, currentTime; + currentTime = startTime = System.currentTimeMillis(); + long stopTime = startTime + 5 * 1000; //5 seconds + do { + if (currentTime % 1000 == 0) { + System.out.print("."); + } + currentTime = System.currentTimeMillis(); + } while (currentTime < stopTime); + + System.out.println(); + System.out.println("Resuming cspace services initialization."); + } + // // Start up and initialize our embedded Nuxeo server instance // diff --git a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java index 6dac00e22..0f1d9aa3f 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java +++ b/services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java @@ -821,7 +821,7 @@ public class AuthorizationCommon { Profiler profiler = new Profiler(AuthorizationCommon.class, 1); profiler.start("createDefaultPermissions started:" + readonlyPerm.getCsid()); persist(em, readonlyPerm, readonlyRole, true); - profiler.stop("createDefaultPermissions finished:" + readonlyPerm.getCsid()); + profiler.stop(); logger.debug("Finished full perm generation for " + ":" + tenantBinding.getId() + ":" + serviceBinding.getName() -- 2.47.3