public OfficeConnection(String openOfficePath, Integer port, ProcessManager processManager, OfficeIntegration officeIntegration) { this.port = port; this.officeIntegration = officeIntegration; this.oooServer = new OOServer(openOfficePath, OOServer.getDefaultOOoOptions(), "localhost", port, processManager); this.bsc = new BootstrapSocketConnector(oooServer); this.openOfficePath = openOfficePath; }
public OfficeIntegration(String openOfficePath, Integer... ports) { this.openOfficePath = openOfficePath; this.openOfficePorts = ports; initConnections(ports); executor = createExecutor(); }
protected OfficeConnection createConnection(Integer port) { return new OfficeConnection(openOfficePath, port, resolveProcessManager(), this); }
protected ProcessManager resolveProcessManager() { if (platformDependProcessManagement) { String os = System.getProperty("os.name").toLowerCase(); if (os.startsWith("windows")) return new WinProcessManager(); if (os.startsWith("linux")) return new LinuxProcessManager(); } return new JavaProcessManager(); } }
protected void convertOnes(final String convertPattern, final byte[] documentBytes, final OutputStream outputStream) throws NoFreePortsException { OfficeTask officeTask = ooResourceProvider -> { try { XComponent xComponent = ooResourceProvider.loadXComponent(documentBytes); saveAndClose(ooResourceProvider, xComponent, outputStream, convertPattern); } catch (Exception e) { throw new ReportingException("An error occurred while running task in Open Office server", e); } }; officeIntegration.runTaskWithTimeout(officeTask, officeIntegration.getTimeoutInSeconds()); }
protected void doCreateDocument(final OutputStream outputStream) throws NoFreePortsException { OfficeTask officeTask = ooResourceProvider -> { try { loadDocument(ooResourceProvider); // Handling tables fillTables(ooResourceProvider.getXDispatchHelper()); // Handling text replaceAllAliasesInDocument(); replaceAllAliasesInDocument();//we do it second time to handle several open office bugs (page breaks in html, etc). Do not remove. // Saving document to output stream and closing saveAndClose(ooResourceProvider, xComponent, outputType, outputStream); } catch (Exception e) { throw wrapWithReportingException("An error occurred while running task in Open Office server", e); } }; officeIntegration.runTaskWithTimeout(officeTask, officeIntegration.getTimeoutInSeconds()); }
public void hardReloadAccessPorts() { for (OfficeConnection connection : connections) { connection.close(); } connectionsQueue.clear(); connectionsQueue.addAll(connections); }
public void close() { bsc.disconnect(); closed = true; } }
/** * Connects to an OOo server using the specified host and port for the * socket and returns a component context for using the connection to the * OOo server. * * @param host The host * @param port The port * @return The component context */ public XComponentContext connect(String host, int port) throws BootstrapException { String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext"; return connect(unoConnectString); } }
public XDispatchHelper getXDispatchHelper() { try { return createXDispatchHelper(); } catch (Exception e) { throw new OpenOfficeException("Unable to create Open office components.", e); } }
protected OfficeConnection acquireConnection() throws NoFreePortsException { final OfficeConnection connection = connectionsQueue.poll(); if (connection != null) { return connection; } else { throw new NoFreePortsException("Couldn't get free port from pool"); } }
/** * Create default local component context. * * @return The default local component context */ protected XComponentContext getLocalContext() throws BootstrapException, Exception { XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null); if (xLocalContext == null) { throw new BootstrapException("no local component context!"); } return xLocalContext; }
public OfficeConnection(String openOfficePath, Integer port, ProcessManager processManager, OfficeIntegration officeIntegration) { this.port = port; this.officeIntegration = officeIntegration; this.oooServer = new OOServer(openOfficePath, OOServer.getDefaultOOoOptions(), "localhost", port, processManager); this.bsc = new BootstrapSocketConnector(oooServer); this.openOfficePath = openOfficePath; }
protected ProcessManager resolveProcessManager() { if (platformDependProcessManagement) { String os = System.getProperty("os.name").toLowerCase(); if (os.startsWith("windows")) return new WinProcessManager(); if (os.startsWith("linux")) return new LinuxProcessManager(); } return new JavaProcessManager(); } }
protected void convertOnes(final String convertPattern, final byte[] documentBytes, final OutputStream outputStream) throws NoFreePortsException { OfficeTask officeTask = ooResourceProvider -> { try { XComponent xComponent = ooResourceProvider.loadXComponent(documentBytes); saveAndClose(ooResourceProvider, xComponent, outputStream, convertPattern); } catch (Exception e) { throw new ReportingException("An error occurred while running task in Open Office server", e); } }; officeIntegration.runTaskWithTimeout(officeTask, officeIntegration.getTimeoutInSeconds()); }
public OfficeIntegration(String openOfficePath, Integer... ports) { this.openOfficePath = openOfficePath; this.openOfficePorts = ports; initConnections(ports); executor = createExecutor(); }
protected OfficeConnection createConnection(Integer port) { return new OfficeConnection(openOfficePath, port, resolveProcessManager(), this); }
public void close() { bsc.disconnect(); closed = true; } }
/** * Connects to an OOo server using the specified host and port for the * socket and returns a component context for using the connection to the * OOo server. * * @param host The host * @param port The port * @return The component context */ public XComponentContext connect(String host, int port) throws BootstrapException { String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext"; return connect(unoConnectString); } }
public XDispatchHelper getXDispatchHelper() { try { return createXDispatchHelper(); } catch (Exception e) { throw new OpenOfficeException("Unable to create Open office components.", e); } }