From: Richard Millet Date: Tue, 17 Dec 2013 23:49:45 +0000 (-0800) Subject: PAHMA-963: Cleaning up some cruft -dead code and unncessary code. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=58935846cf98bbd2fa56203b1613182ecdf59844;p=tmp%2Fjakarta-migration.git PAHMA-963: Cleaning up some cruft -dead code and unncessary code. --- diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java index e54709a13..557b59c69 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java @@ -32,7 +32,7 @@ public class BlobScaleTest extends BaseServiceTest { private static final int MAX_FONTSIZE = 60; private static final String IMAGES_TO_CREATE_PROP = "imagesToCreate"; private static final int DEFAULT_IMAGES_TO_CREATE = 1; - private static final int DEFAULT_IMAGES_TO_GET = 1024; + private static final int DEFAULT_IMAGES_TO_GET = 12; //1024; private static final String GENERATED_IMAGES = "target/generated_images"; private static Random generator = new Random(System.currentTimeMillis()); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java index 121abc2d5..1f2330ab6 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java @@ -22,10 +22,8 @@ package org.collectionspace.services.nuxeo.client.java; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Vector; import javax.security.auth.login.AppConfigurationEntry; import javax.transaction.TransactionManager; @@ -42,7 +40,7 @@ import org.nuxeo.ecm.core.api.repository.RepositoryManager; import org.nuxeo.ecm.core.client.ConnectionListener; import org.nuxeo.ecm.core.client.DefaultLoginHandler; import org.nuxeo.ecm.core.client.LoginHandler; -import org.nuxeo.ecm.core.repository.RepositoryDescriptor; +//import org.nuxeo.ecm.core.repository.RepositoryDescriptor; import org.nuxeo.ecm.core.schema.SchemaManager; import org.nuxeo.ecm.core.schema.SchemaManagerImpl; import org.nuxeo.ecm.core.schema.TypeProvider; @@ -81,8 +79,6 @@ public final class NuxeoClientEmbedded { private RepositoryManager repositoryMgr; - private boolean multiThreadedLogin = false; - private static final NuxeoClientEmbedded instance = new NuxeoClientEmbedded(); private static final Log log = LogFactory.getLog(NuxeoClientEmbedded.class); @@ -103,161 +99,8 @@ public final class NuxeoClientEmbedded { return instance; } - public void setMultiThreadedLogin(boolean useMultiThreadedLogin) { - multiThreadedLogin = useMultiThreadedLogin; - } - - public boolean getMultiThreadedLogin() { - return multiThreadedLogin; - } - - public synchronized void connect(String locator) throws Exception { - if (this.locator != null) { - throw new IllegalStateException("Client is already connected"); - } - doConnect(AutoConfigurationService.createLocator(locator)); - } - - public synchronized void connect(InvokerLocator locator) throws Exception { - if (this.locator != null) { - throw new IllegalStateException("Client is already connected"); - } - doConnect(locator); - } - - public synchronized void connect(String host, int port) throws Exception { - if (locator != null) { - throw new IllegalStateException("Client is already connected"); - } - doConnect(AutoConfigurationService.createLocator(host, port)); - } - - public synchronized void forceConnect(InvokerLocator locator) - throws Exception { - if (this.locator != null) { - disconnect(); - } - doConnect(locator); - } - - public synchronized void forceConnect(String locator) throws Exception { - if (this.locator != null) { - disconnect(); - } - doConnect(AutoConfigurationService.createLocator(locator)); - } - - public synchronized void forceConnect(String host, int port) - throws Exception { - if (locator != null) { - disconnect(); - } - doConnect(AutoConfigurationService.createLocator(host, port)); - } - - public synchronized void tryConnect(String host, int port) throws Exception { - if (locator != null) { - return; // do nothing - } - doConnect(AutoConfigurationService.createLocator(host, port)); - } - - public synchronized void tryConnect(String url) throws Exception { - if (locator != null) { - return; // do nothing - } - doConnect(AutoConfigurationService.createLocator(url)); - } - - public synchronized void tryConnect(InvokerLocator locator) - throws Exception { - if (this.locator != null) { - return; // do nothing - } - doConnect(locator); - } - @Deprecated - private void doConnect(InvokerLocator locator) throws Exception { - this.locator = locator; - try { - cfg.load(locator); - // FIXME TODO workaround to work with nxruntime core 1.3.3 - // -------------- - String newPort = Framework.getProperty("org.nuxeo.runtime.1.3.3.streaming.port"); - if (newPort != null) { - StreamingService streamingService = (StreamingService) Framework.getRuntime().getComponent( - StreamingService.NAME); - // streaming config - String oldLocator = streamingService.getServerLocator(); - int p = oldLocator.lastIndexOf(':'); - if (p > -1) { - String withoutPort = oldLocator.substring(0, p); - String serverLocator = withoutPort + ":" + newPort; - streamingService.stopManager(); - streamingService.setServerLocator(serverLocator); - streamingService.setServer(false); - streamingService.startManager(); - } - } - // FIXME TODO workaround for remote services - // ------------------------------- - schemaRemotingWorkaround(locator.getHost()); - // workaround for client login configuration - we need to make it - // not multi threaded - // TODO put an option for this in NuxeoClient - if (!multiThreadedLogin) { - LoginService ls = Framework.getService(LoginService.class); - SecurityDomain sysDomain = ls.getSecurityDomain(LoginComponent.SYSTEM_LOGIN); - SecurityDomain clientDomain = ls.getSecurityDomain(LoginComponent.CLIENT_LOGIN); - adaptClientSecurityDomain(sysDomain); - adaptClientSecurityDomain(clientDomain); - } - // ---------------- -// login(); - if (!multiThreadedLogin) { - throw new RuntimeException("This coode is dead and should never be called?"); //FIXME: REM - If you're reading this, this was left here by mistake and should be removed. - } - } catch (Exception e) { - this.locator = null; - throw e; - } - fireConnected(this); - } - - public static void adaptClientSecurityDomain(SecurityDomain sd) { - AppConfigurationEntry[] entries = sd.getAppConfigurationEntries(); - if (entries != null) { - for (int i = 0; i < entries.length; i++) { - AppConfigurationEntry entry = entries[i]; - if ("org.jboss.security.ClientLoginModule".equals(entry.getLoginModuleName())) { - Map opts = entry.getOptions(); - Map newOpts = new HashMap( - opts); - newOpts.put("multi-threaded", "false"); - entries[i] = new AppConfigurationEntry( - entry.getLoginModuleName(), entry.getControlFlag(), - entry.getOptions()); - } - } - } - } - - /** - * Workaround for being able to load schemas from remote - * TODO integrate this in core - */ - private static void schemaRemotingWorkaround(String host) throws Exception { - ServiceManager serviceManager = Framework.getLocalService(ServiceManager.class); - ServiceDescriptor sd = new ServiceDescriptor(TypeProvider.class, "core"); - sd.setLocator("%TypeProviderBean"); - serviceManager.registerService(sd); - TypeProvider typeProvider = Framework.getService(TypeProvider.class); - SchemaManager schemaMgr = Framework.getLocalService(SchemaManager.class); - ((SchemaManagerImpl) schemaMgr).importTypes(typeProvider); - } - - public synchronized void disconnect() throws Exception { + private synchronized void disconnect() throws Exception { if (locator == null) { throw new IllegalStateException("Client is not connected"); } @@ -271,7 +114,6 @@ public final class NuxeoClientEmbedded { doDisconnect(); } - @Deprecated private void doDisconnect() throws Exception { locator = null; serverName = null; @@ -286,26 +128,8 @@ public final class NuxeoClientEmbedded { } it.remove(); } - // logout -// logout(); - if (!multiThreadedLogin) { - throw new RuntimeException("This coode is dead and should never be called?"); //FIXME: REM - If you're reading this, this was left here by mistake and should be removed. - } - repositoryMgr = null; - fireDisconnected(this); - } - - public synchronized void reconnect() throws Exception { - if (locator == null) { - throw new IllegalStateException("Client is not connected"); - } - InvokerLocator locator = this.locator; - disconnect(); - connect(locator); - } - public AutoConfigurationService getConfigurationService() { - return cfg; + repositoryMgr = null; } public synchronized String getServerName() { @@ -327,20 +151,6 @@ public final class NuxeoClientEmbedded { return true; } - public String getServerHost() { - if (locator == null) { - throw new IllegalStateException("Client is not connected"); - } - return locator.getHost(); - } - - public int getServerPort() { - if (locator == null) { - throw new IllegalStateException("Client is not connected"); - } - return locator.getPort(); - } - public InvokerLocator getLocator() { return locator; } @@ -475,37 +285,8 @@ public final class NuxeoClientEmbedded { } } -// public RepositoryInstance[] getRepositoryInstances() { -// return repositoryInstances.toArray(new RepositoryInstance[repositoryInstances.size()]); -// } - public static RepositoryInstance newRepositoryInstance(Repository repository) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = NuxeoClientEmbedded.class.getClassLoader(); - } return new RepositoryInstanceHandler(repository).getProxy(); // Why a proxy here? } - public void addConnectionListener(ConnectionListener listener) { - connectionListeners.add(listener); - } - - public void removeConnectionListener(ConnectionListener listener) { - connectionListeners.remove(listener); - } - - private void fireDisconnected(NuxeoClientEmbedded client) { - Object[] listeners = connectionListeners.getListeners(); - for (Object listener : listeners) { -// ((ConnectionListener) listener).disconnected(client); - } - } - - private void fireConnected(NuxeoClientEmbedded client) { - Object[] listeners = connectionListeners.getListeners(); - for (Object listener : listeners) { -// ((ConnectionListener) listener).connected(client); - } - } } diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java index f8f462342..3da583a9b 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java @@ -2,7 +2,6 @@ package org.collectionspace.services.nuxeo.client.java; import java.io.File; import java.io.IOException; -import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; @@ -38,17 +37,10 @@ public class NuxeoConnectorEmbedded { public final static String NUXEO_CLIENT_DIR = JEEServerDeployment.NUXEO_CLIENT_DIR; public final static String NUXEO_SERVER_DIR = JEEServerDeployment.NUXEO_SERVER_DIR; private final static String ERROR_CONNECTOR_NOT_INITIALIZED = "NuxeoConnector is not initialized!"; - - - private static final String HOST = "127.0.0.1"; - private static final int PORT = 62474; private final static String CSPACE_JEESERVER_HOME = "CSPACE_CONTAINER"; private final static String CSPACE_NUXEO_HOME = "CSPACE_NUXEO_HOME"; - private static final String NUXEO_CLIENT_USERNAME = "NUXEO_CLIENT_USERNAME"; - private static final String NUXEO_CLIENT_PASSWORD = "NUXEO_CLIENT_PASSWORD"; - private static final NuxeoConnectorEmbedded self = new NuxeoConnectorEmbedded(); private NuxeoClientEmbedded client; private ServletContext servletContext = null; @@ -64,33 +56,6 @@ public class NuxeoConnectorEmbedded { public final static NuxeoConnectorEmbedded getInstance() { return self; } - - private String getClientUserName() { - String username = System.getenv(NUXEO_CLIENT_USERNAME); - if (username == null) { - username = "Administrator"; - } - return username; - } - - private String getClientPassword() { - String password = System.getenv(NUXEO_CLIENT_PASSWORD); - if (password == null) { - password = "Administrator"; - } - return password; - } - - private String getServerRootPath() { - String result = null; - - String prop = System.getenv(CSPACE_JEESERVER_HOME); - if (prop == null || prop.isEmpty()) { - logger.error("The following CollectionSpace services' environment variable needs to be set: " + CSPACE_JEESERVER_HOME); - } - - return result; - } private String getNuxeoServerPath(String serverRootPath) throws IOException { String result = null; @@ -204,6 +169,7 @@ public class NuxeoConnectorEmbedded { // TODO Auto-generated catch block e.printStackTrace(); } + ConnectionFactoryImpl connectionFactory = (ConnectionFactoryImpl)repository; ManagedConnectionFactoryImpl managedConnectionFactory = connectionFactory.getManagedConnectionFactory(); String serverUrl = managedConnectionFactory.getServerURL(); @@ -236,11 +202,13 @@ public class NuxeoConnectorEmbedded { */ public RepositoryInstance getRepositorySession(RepositoryDomainType repoDomain) throws Exception { RepositoryInstance repoSession = getClient().openRepository(repoDomain); + if (logger.isDebugEnabled() && repoSession != null) { logger.debug("getRepositorySession() opened repository session"); String repoName = repoDomain.getRepositoryName(); String databaseName = this.getDatabaseName(repoName); // For debugging purposes only } + return repoSession; } @@ -268,7 +236,6 @@ public class NuxeoConnectorEmbedded { public RepositoryDescriptor getRepositoryDescriptor(String name) throws Exception { RepositoryDescriptor repo = null; - Iterable descriptorsList = NXCore.getRepositoryService().getRepositoryManager().getDescriptors(); for (RepositoryDescriptor descriptor : descriptorsList) { String homeDir = descriptor.getHomeDirectory(); @@ -289,15 +256,6 @@ public class NuxeoConnectorEmbedded { public NuxeoClientEmbedded getClient() throws Exception { if (initialized == true) { if (client.isConnected()) { -// client.login(); - return client; - } else { - client.forceConnect(this.HOST, - this.PORT); - if (logger.isDebugEnabled()) { - logger.debug("getClient(): connection successful port=" - + this.PORT); - } return client; } } @@ -310,7 +268,7 @@ public class NuxeoConnectorEmbedded { void releaseClient() throws Exception { if (initialized == true) { -// client.logout(); + // Do nothing. } else { // // Nuxeo connection was not initialized @@ -378,11 +336,7 @@ public class NuxeoConnectorEmbedded { releaseRepositorySession(repoSession); } } + return workspaceIds; - } - - @Deprecated - private void loadBundles() throws Exception { - } - + } }