/** * Returns the DOM document as an XML string. */ @Override public String toString() { try { return new String(toBuffer(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new MarkLogicIOException(e); } }
/** * Returns the DOM document as an XML string. */ @Override public String toString() { try { byte[] buffer = toBuffer(); if ( buffer == null ) return null; else return new String(buffer,"UTF-8"); } catch (UnsupportedEncodingException e) { throw new MarkLogicIOException(e); } }
@Override public List<File> exportWorkspaces(String user, String... workspaceNames) { if (baseDir == null) { baseDir = getDefaultWorkspacesDir(); } File userDir = new File(baseDir, user); userDir.mkdirs(); List<File> files = new ArrayList<>(); for (String workspaceName : workspaceNames) { EvalResultIterator result = client.newServerEval() .addVariable("user", user) .addVariable("workspace", workspaceName) .xquery(QconsoleScripts.EXPORT).eval(); while (result.hasNext()) { DOMHandle dom = result.next().get(new DOMHandle()); File f = new File(userDir, workspaceName + ".xml"); try { FileCopyUtils.copy(dom.toBuffer(), f); if (logger.isInfoEnabled()) { logger.info(format("Exported workspace %s to %s", workspaceName, f.getAbsolutePath())); } files.add(f); } catch (IOException ie) { throw new RuntimeException("Unable to write workspace XML to file, workspace: " + workspaceName + "; cause: " + ie.getMessage()); } } } return files; }