@Test public void testGetRepository() throws Exception { MarkLogicRepositoryConfig config = new MarkLogicRepositoryConfig(); config.setHost(host); config.setPort(port); config.setUser(adminUser); config.setPassword(adminPassword); config.setAuth("DIGEST"); RepositoryFactory factory = new MarkLogicRepositoryFactory(); Assert.assertEquals("marklogic:MarkLogicRepository", factory.getRepositoryType()); Repository repo = factory.getRepository(config); repo.initialize(); Assert.assertTrue(repo.getConnection() instanceof MarkLogicRepositoryConnection); Repository otherrepo = factory.getRepository(config); otherrepo.initialize(); RepositoryConnection oconn = otherrepo.getConnection(); Assert.assertTrue(oconn instanceof MarkLogicRepositoryConnection); }
@Override public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException { MarkLogicRepository repo = null; MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config; if (cfg.getHost() != null && cfg.getPort() != 0) { repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth()); } else if (cfg.getHost() == null) { try { repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl())); } catch (MalformedURLException e) { logger.debug(e.getMessage()); throw new RepositoryConfigException(e.getMessage()); } }else{ throw new RepositoryConfigException("Invalid configuration class: " + config.getClass()); } return repo; }
MarkLogicRepositoryFactory implements RepositoryFactory { @Override public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException { MarkLogicRepository repo = null; MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config; if (cfg.getHost() != null && cfg.getPort() != 0) { repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth()); } else if (cfg.getHost() == null) { try { repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl())); } catch (MalformedURLException e) { logger.debug(e.getMessage()); throw new RepositoryConfigException(e.getMessage()); } }else{ throw new RepositoryConfigException("Invalid configuration class: " + config.getClass()); } return repo; } }
MarkLogicRepositoryFactory implements RepositoryFactory { @Override public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException { MarkLogicRepository repo = null; MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config; if (cfg.getHost() != null && cfg.getPort() != 0) { repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth()); } else if (cfg.getHost() == null) { try { repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl())); } catch (MalformedURLException e) { logger.debug(e.getMessage()); throw new RepositoryConfigException(e.getMessage()); } }else{ throw new RepositoryConfigException("Invalid configuration class: " + config.getClass()); } return repo; }  }
MarkLogicRepositoryFactory implements RepositoryFactory { @Override public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException { MarkLogicRepository repo = null; MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config; if (cfg.getHost() != null && cfg.getPort() != 0) { repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth()); } else if (cfg.getHost() == null) { try { repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl())); } catch (MalformedURLException e) { logger.debug(e.getMessage()); throw new RepositoryConfigException(e.getMessage()); } }else{ throw new RepositoryConfigException("Invalid configuration class: " + config.getClass()); } return repo; }  @Override /** * returns repository type * */ String getRepositoryType(); @Override /** * returns config * */ RepositoryImplConfig getConfig(); @Override /** * instantiate and return repository * */ Repository getRepository(RepositoryImplConfig config); }
MarkLogicRepositoryFactory implements RepositoryFactory { @Override public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException { MarkLogicRepository repo = null; MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config; if (cfg.getHost() != null && cfg.getPort() != 0) { repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth()); } else if (cfg.getHost() == null) { try { repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl())); } catch (MalformedURLException e) { logger.debug(e.getMessage()); throw new RepositoryConfigException(e.getMessage()); } }else{ throw new RepositoryConfigException("Invalid configuration class: " + config.getClass()); } return repo; }  @Override /** * returns repository type * */ String getRepositoryType(); @Override /** * returns config * */ RepositoryImplConfig getConfig(); @Override /** * instantiate and return repository * */ Repository getRepository(RepositoryImplConfig config); static final String REPOSITORY_TYPE; }