/** * INTERNAL: * Build the nested record, this can be overwriten by subclasses to use their subclass instance. */ public XMLRecord buildNestedRow(Element element) { if (getRecord() != null) { return new EISDOMRecord(getRecord(), element); } else { return new EISDOMRecord(element); } } }
/** * Execute the interaction and set the output into the output record. * Return true or false if the execute returned data (similar to row-count). */ public boolean execute(InteractionSpec spec, Record input, Record output) throws ResourceException { EISDOMRecord result = (EISDOMRecord)execute(spec, input); if (result == null) { return false; } ((EISDOMRecord)output).setDOM(result.getDOM()); return true; }
/** * Default constructor. */ public EISDOMRecord() { super(); setRecordName(""); setRecordShortDescription(""); }
public MappedRecord createMappedRecord(String recordName) { EISDOMRecord record = new EISDOMRecord(); record.setRecordName(recordName); return record; } }
Object result = fileRecord.getValues(buildField(spec)); EISDOMRecord output = new EISDOMRecord(); if (result instanceof List) { List results = (List)result; output.setDOM(output.createNewDocument("results")); if (results != null) { for (int index = 0; index < results.size(); index++) { output.add(new DatabaseField("result"), results.get(index)); output.setDOM(output.createNewDocument("results")); output.add(new DatabaseField("result"), result);
/** * Return the transactional copy of the file's DOM record. * This will be written on commit. */ public EISDOMRecord retrieveDOMRecord(File file) throws Exception { // Check for transactional copy. EISDOMRecord fileRecord = (EISDOMRecord)this.domFiles.get(file.getPath()); if (fileRecord == null) { // If the file exists parse it, otherwise create a new record. if (file.exists()) { Reader fileReader = new FileReader(file); fileRecord = new EISDOMRecord(); // Parse file. fileRecord.transformFromXML(fileReader); fileReader.close(); } else { fileRecord = new EISDOMRecord(); fileRecord.setDOM(fileRecord.createNewDocument("root")); } this.domFiles.put(file.getPath(), fileRecord); } return fileRecord; } }
/** * Return the string for logging purposes. */ public String getLogString(Accessor accessor) { StringWriter writer = new StringWriter(); writer.write("Executing "); writer.write(toString()); writer.write(Helper.cr()); writer.write("\tspec => "); writer.write(String.valueOf(getInteractionSpec())); writer.write(Helper.cr()); writer.write("\tproperties => "); writer.write(String.valueOf(getProperties())); writer.write(Helper.cr()); writer.write("\txml => "); Element dom = createInputDOM((EISAccessor)accessor); EISDOMRecord record = new EISDOMRecord(dom); record.transformToWriter(writer); return writer.toString(); }
/** * Allow the platform to handle the creation of the Record for the DOM record. * Translate the indexed record text into a DOM record. */ public AbstractRecord createDatabaseRowFromDOMRecord(Record record, EISInteraction call, EISAccessor accessor) { IndexedRecord indexedRecord = (IndexedRecord)record; if (indexedRecord.size() == 0) { return null; } EISDOMRecord domRecord = new EISDOMRecord(); // the record is assumed to contain either: // - a TextMessage object if a converter was not defined // - a string of XML if a converter was defined Object recordData = indexedRecord.get(0); if (recordData instanceof TextMessage) { try { domRecord.transformFromXML(((TextMessage)recordData).getText()); } catch (Exception ex) { return null; } } else if (recordData instanceof String) { domRecord.transformFromXML((String)recordData); } else { throw EISException.unsupportedMessageInOutputRecord(); } return domRecord; } }
/** * INTERNAL: * Allow the platform to handle the creation of the Record for the DOM record. * By default instantiate an EISDOMRecord which introspects the record for a getDOM method. */ public AbstractRecord createDatabaseRowFromDOMRecord(Record record, EISInteraction call, EISAccessor accessor) { return new EISDOMRecord(record); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ setDOM((Element)AccessController.doPrivileged(new PrivilegedMethodInvoker(domMethod, record, null))); }catch (PrivilegedActionException ex){ throw (Exception)ex.getCause(); setDOM((Element)PrivilegedAccessHelper.invokeMethod(domMethod, record, null));
/** * Write each of the transactional DOM records back to their files. */ @Override public void commit() throws ResourceException { try { // store any dom to their files for (Iterator doms = domFiles.entrySet().iterator(); doms.hasNext();) { Map.Entry entry = (Map.Entry)doms.next(); String fileName = (String)entry.getKey(); EISDOMRecord record = (EISDOMRecord)entry.getValue(); try (Writer fileWriter = new FileWriter(fileName)) { record.transformToWriter(fileWriter); fileWriter.flush(); } } } catch (Exception exception) { throw new ResourceException(exception.toString()); } this.domFiles = new HashMap(10); this.isInTransaction = false; }
((EISDOMRecord) recordToReturn).setSession(((EISDOMRecord)input).getSession());
/** * Execute the insert operation. */ public Record executeInsert(XMLFileInteractionSpec spec, File file, EISDOMRecord input) throws Exception { // Write input record dom to file, or insert dom node. EISDOMRecord outputToFile = input; // If xpath, parse, insert node, then write back if (spec.getXPath() != null) { // If the file exists get tx dom. outputToFile = connection.getXMLFileTransaction().retrieveDOMRecord(file); outputToFile.add(buildField(spec), input); } return null; }
/** * Execute the read operation. */ public Record executeRead(XMLFileInteractionSpec spec, File file) throws Exception { // Parse file and return document, or xpath/xquery result from dom. if (!file.exists()) { return null; } EISDOMRecord fileRecord = connection.getXMLFileTransaction().retrieveDOMRecord(file); // Check for and process XPath or XQuery if (spec.getXPath() != null) { // Either a value/string or list of element records is returned Object result = fileRecord.getValues(buildField(spec)); EISDOMRecord output = new EISDOMRecord(); if (result instanceof List) { List results = (List)result; output.setDOM(output.createNewDocument("results")); for (int index = 0; index < results.size(); index++) { output.add(new DatabaseField("result"), results.get(index)); } } else { output.setDOM(output.createNewDocument("results")); output.add(new DatabaseField("result"), result); } return output; } else { return fileRecord; } }
/** * Return the transactional copy of the file's DOM record. * This will be written on commit. */ public EISDOMRecord retrieveDOMRecord(File file) throws Exception { // Check for transactional copy. EISDOMRecord fileRecord = (EISDOMRecord)this.domFiles.get(file.getPath()); if (fileRecord == null) { // If the file exists parse it, otherwise create a new record. if (file.exists()) { Reader fileReader = new FileReader(file); fileRecord = new EISDOMRecord(); // Parse file. fileRecord.transformFromXML(fileReader); fileReader.close(); } else { fileRecord = new EISDOMRecord(); fileRecord.setDOM(fileRecord.createNewDocument("root")); } this.domFiles.put(file.getPath(), fileRecord); } return fileRecord; } }
/** * Return the string for logging purposes. */ public String getLogString(Accessor accessor) { StringWriter writer = new StringWriter(); writer.write("Executing "); writer.write(toString()); writer.write(Helper.cr()); writer.write("\tspec => "); writer.write(String.valueOf(getInteractionSpec())); writer.write(Helper.cr()); writer.write("\tproperties => "); writer.write(String.valueOf(getProperties())); writer.write(Helper.cr()); writer.write("\txml => "); Element dom = createInputDOM((EISAccessor)accessor); EISDOMRecord record = new EISDOMRecord(dom); record.transformToWriter(writer); return writer.toString(); }
public MappedRecord createMappedRecord(String recordName) { EISDOMRecord record = new EISDOMRecord(); record.setRecordName(recordName); return record; } }
/** * Allow the platform to handle the creation of the Record for the DOM record. * Translate the indexed record text into a DOM record. */ public AbstractRecord createDatabaseRowFromDOMRecord(Record record, EISInteraction call, EISAccessor accessor) { IndexedRecord indexedRecord = (IndexedRecord)record; if (indexedRecord.size() == 0) { return null; } EISDOMRecord domRecord = new EISDOMRecord(); // the record is assumed to contain either: // - a TextMessage object if a converter was not defined // - a string of XML if a converter was defined Object recordData = indexedRecord.get(0); if (recordData instanceof TextMessage) { try { domRecord.transformFromXML(((TextMessage)recordData).getText()); } catch (Exception ex) { return null; } } else if (recordData instanceof String) { domRecord.transformFromXML((String)recordData); } else { throw EISException.unsupportedMessageInOutputRecord(); } return domRecord; } }
/** * INTERNAL: * Allow the platform to handle the creation of the Record for the DOM record. * By default instantiate an EISDOMRecord which introspects the record for a getDOM method. */ public AbstractRecord createDatabaseRowFromDOMRecord(Record record, EISInteraction call, EISAccessor accessor) { return new EISDOMRecord(record); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ setDOM((Element)AccessController.doPrivileged(new PrivilegedMethodInvoker(domMethod, record, null))); }catch (PrivilegedActionException ex){ throw (Exception)ex.getCause(); setDOM((Element)PrivilegedAccessHelper.invokeMethod(domMethod, record, null));