- nodeSecurity = new NodeSecurity(bundleContext, node);
- nodeHttp = new NodeHttp(bundleContext, node, nodeSecurity);
-
- // Publish services to OSGi
- nodeSecurity.publish();
- node.publish();
- bundleContext.registerService(RepositoryFactory.class,
- repositoryFactory, null);
- nodeHttp.publish();
-
- if ("false".equals(bundleContext
- .getProperty(PROP_WORKBENCH_AUTOSTART))) {
- WorkbenchApplicationConfiguration wac = new WorkbenchApplicationConfiguration();
- registerWorkbench(wac);
+ Repository remoteRepository = ArgeoJcrUtils.getRepositoryByUri(
+ repositoryFactory, uri);
+ Session remoteSession = remoteRepository
+ .login(new SimpleCredentials("root", "demo".toCharArray()),
+ "main");
+ Session localSession = this.repository.login();
+ // FIXME register node type
+ // if (false)
+ // CndImporter.registerNodeTypes(null, localSession);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ remoteSession.exportSystemView("/", out, true, false);
+ ByteArrayInputStream in = new ByteArrayInputStream(
+ out.toByteArray());
+ localSession.importXML("/", in,
+ ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ // JcrUtils.copy(remoteSession.getRootNode(),
+ // localSession.getRootNode());
+ } catch (Exception e) {
+ throw new CmsException("Cannot first init from " + uri, e);
+ }
+ }
+
+ /** Can be null */
+ private ConfigurationAdmin findConfigurationAdmin() {
+ configurationAdmin = bc.getServiceReference(ConfigurationAdmin.class);
+ if (configurationAdmin == null) {
+ return null;
+ }
+ return bc.getService(configurationAdmin);
+ }
+
+ private void initTransactionManager() {
+ bitronix.tm.Configuration tmConf = TransactionManagerServices
+ .getConfiguration();
+ tmConf.setServerId(getFrameworkProp(FRAMEWORK_UUID));
+
+ // File tmBaseDir = new File(getFrameworkProp(TRANSACTIONS_HOME,
+ // getOsgiInstancePath(DIR_TRANSACTIONS)));
+ File tmBaseDir = bc.getDataFile(DIR_TRANSACTIONS);
+ File tmDir1 = new File(tmBaseDir, "btm1");
+ tmDir1.mkdirs();
+ tmConf.setLogPart1Filename(new File(tmDir1, tmDir1.getName() + ".tlog")
+ .getAbsolutePath());
+ File tmDir2 = new File(tmBaseDir, "btm2");
+ tmDir2.mkdirs();
+ tmConf.setLogPart2Filename(new File(tmDir2, tmDir2.getName() + ".tlog")
+ .getAbsolutePath());
+ transactionManager = getTransactionManager();
+ transactionSynchronizationRegistry = getTransactionSynchronizationRegistry();
+ }
+
+ private void initWebServer(ConfigurationAdmin conf) {
+ String httpPort = getFrameworkProp("org.osgi.service.http.port");
+ String httpsPort = getFrameworkProp("org.osgi.service.http.port.secure");
+ try {
+ if (httpPort != null || httpsPort != null) {
+ Hashtable<String, Object> jettyProps = new Hashtable<String, Object>();
+ if (httpPort != null) {
+ jettyProps.put(JettyConstants.HTTP_PORT, httpPort);
+ jettyProps.put(JettyConstants.HTTP_ENABLED, true);
+ }
+ if (httpsPort != null) {
+ jettyProps.put(JettyConstants.HTTPS_PORT, httpsPort);
+ jettyProps.put(JettyConstants.HTTPS_ENABLED, true);
+ jettyProps.put(JettyConstants.SSL_KEYSTORETYPE, "PKCS12");
+ jettyProps.put(JettyConstants.SSL_KEYSTORE, nodeSecurity
+ .getHttpServerKeyStore().getCanonicalPath());
+ jettyProps.put(JettyConstants.SSL_PASSWORD, "changeit");
+ jettyProps.put(JettyConstants.SSL_WANTCLIENTAUTH, true);
+ }
+ if (conf != null) {
+ // TODO make filter more generic
+ String filter = "(" + JettyConstants.HTTP_PORT + "="
+ + httpPort + ")";
+ if (conf.listConfigurations(filter) != null)
+ return;
+ Configuration jettyConf = conf.createFactoryConfiguration(
+ JETTY_FACTORY_PID, null);
+ jettyConf.update(jettyProps);
+ } else {
+ JettyConfigurator.startServer("default", jettyProps);
+ }