public DocumentAccessor call() throws Exception { return docMgr.storeDocument(uri, content, context); } });
DocumentAccessor storeDocument(String uri, String xml) throws Exception { return xRepo.getDocumentManagement().storeDocument(uri, xml, props); }
private String storeDocument(String uri, String xml) { try { Properties props = new Properties(); props.setProperty(pn_document_data_format, "XML"); DocumentAccessor doc = xRepo.getDocumentManagement().storeDocument(uri, xml, props); //logger.trace("storeDocument.exit; result: {}", result); return doc.getUri(); } catch (BagriException ex) { return null; } }
private int storeDocument(String uri, String content) throws BagriException { Properties props = new Properties(); props.setProperty(pn_document_data_format, "XML"); DocumentAccessor xDoc = xRepo.getDocumentManagement().storeDocument(uri, content, props); return xDoc.getVersion(); }
public DocumentAccessor createDocumentTest(String fileName) throws Exception { String uri = Paths.get(fileName).getFileName().toString(); String content = readTextFile(fileName); Properties props = getDocumentProperties(); return getDocManagement().storeDocument(uri, content, props); }
private boolean storeDocument(int idx, String[] header, String[] data, String uri, Properties props) { //throws XDMException { Map<String, Object> map = line2Map(header, data); if (map != null) { try { DocumentAccessor doc = xRepo.getDocumentManagement().storeDocument(uri, map, props); return doc != null; } catch (BagriException ex) { System.out.println("failed map is: " + map + ". record idx is: " + (idx + 2)); return false; } } System.out.println("was not able convert record to map. record idx is: " + (idx + 2)); return false; }
@ManagedOperation(description="Register Document") @ManagedOperationParameters({ @ManagedOperationParameter(name = "docFile", description = "A full path to XML file to register"), @ManagedOperationParameter(name = "properties", description = "A list of properties in key=value form separated by semicolon")}) public String registerDocument(String docFile, String properties) { String uri = Paths.get(docFile).getFileName().toString(); try { String xml = FileUtils.readTextFile(docFile); DocumentAccessor doc = docManager.storeDocument(uri, xml, propsFromString(properties)); return doc.getUri(); } catch (IOException | BagriException ex) { logger.error("registerDocument.error: {}", ex.getMessage(), ex); throw new RuntimeException(ex.getMessage()); } }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "postDocument: creates a new Document or new version if Document with provided uri already exists") public Response postDocument(final DocumentParams params) { DocumentManagement docMgr = getDocManager(); try { logger.trace("postDocument; got params: {}", params); DocumentAccessor doc = docMgr.storeDocument(params.uri, params.content, params.props); logger.trace("postDocument; got document: {}", doc); DocumentBean dr = new DocumentBean(doc.getUri(), doc.getCreateadAt(), doc.getCreatedBy(), doc.getContentType(), doc.getEncoding(), doc.getSizeInBytes()); return Response.created(UriBuilder.fromPath("/docs/" + dr.uri).build()).entity(dr).build(); } catch (Exception ex) { logger.error("postDocument.error", ex); throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR); //return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build(); } }
public DocumentAccessor updateDocumentTest(String uri, String fileName) throws Exception { String content = readTextFile(fileName); Properties props = getDocumentProperties(); return getDocManagement().storeDocument(uri, content, props); }
@Override public DocumentAccessor call() throws Exception { checkPermission(Permission.Value.modify); TransactionIsolation tiLevel = ((SchemaRepositoryImpl) repo).getTransactionLevel(context); if (tiLevel == null) { // bypass tx stack completely! return docMgr.storeDocument(uri, content, context); } return txMgr.callInTransaction(txId, false, tiLevel, new Callable<DocumentAccessor>() { public DocumentAccessor call() throws Exception { return docMgr.storeDocument(uri, content, context); } }); }
} else { String content = readTextFile(fileName, encoding); DocumentAccessor doc = dMgr.storeDocument(fn, content, props); return 1;
@ManagedOperation(description="Updates already registerd Document") @ManagedOperationParameters({ @ManagedOperationParameter(name = "uri", description = "A new uri for the file or null"), @ManagedOperationParameter(name = "docFile", description = "A full path to XML file to register"), @ManagedOperationParameter(name = "properties", description = "A list of properties in key=value form separated by semicolon")}) public String updateDocument(String uri, String docFile, String properties) { try { String content = FileUtils.readTextFile(docFile); DocumentAccessor doc = docManager.storeDocument(uri, content, propsFromString(properties)); return doc.getUri(); } catch (IOException | BagriException ex) { logger.error("updateDocument.error: {}", ex.getMessage(), ex); throw new RuntimeException(ex.getMessage()); } }
DocumentAccessor doc = dMgr.storeDocument(uri, xml, null); List<Object> result = new ArrayList<>(1); result.add(doc);
String content = ((XQItem) params.remove("content")).getAtomicValue(); String uri = getDocumentUri(params); result = getDocumentManagement().storeDocument(uri, content, fillProperties(params, props)); } else if (command.equals(cmd_get_document)) { String uri = getDocumentUri(params);
@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { String uri = arguments[0].head().getStringValue(); Item item = arguments[1].head(); Object content = SaxonUtils.itemToObject(item); Properties props = null; if (arguments.length > 2) { props = sequence2Properties(arguments[2]); } try { DocumentAccessor doc = xdm.storeDocument(uri, content, props); return new AnyURIValue(doc.getUri()); } catch (BagriException ex) { throw new XPathException(ex); } }