Document doc = StorageUtils.createDocument(); Stack stack = new Stack(); Element root = doc.createElement(m_rootTagName);
/** * Create a new DOM Document. * * @return A new DOM document. */ public static Document createDocument() { try { DocumentBuilder builder = getDocumentBuilder(); Document doc = builder.newDocument(); return doc; } catch (Exception any) { log.warn("createDocument: " + any.toString()); return null; } }
/** * Process a string of XML using SAX and a default handler * @param in * @param dh * @throws SAXException * @throws IOException */ public static void processString( String in, DefaultHandler dh ) throws SAXException, IOException { Reader r = new StringReader(in); processReader(r,dh); r.close(); }
SAXEntityReader sm_user = (SAXEntityReader) m_user; DefaultEntityHandler deh = sm_user.getDefaultHandler(sm_user.getServices()); StorageUtils.processString(xml, deh); return deh.getEntity(); } else { Document doc = StorageUtils.readDocumentFromString(xml);
Document doc = StorageUtils.createDocument(); entry.toXml(doc, new Stack()); String xml = StorageUtils.writeDocumentToString(doc);
/** * Load the Xml Document */ protected Document load() { return StorageUtils.readDocument(m_fileStoragePath); }
/** * flush */ protected void flush() { Document doc = createDocument(); StorageUtils.writeDocument(doc, m_fileStoragePath); }
Document doc = StorageUtils.createDocument(); entry.toXml(doc, new Stack()); String xml = StorageUtils.writeDocumentToString(doc);
SAXEntityReader sm_user = (SAXEntityReader) m_user; DefaultEntityHandler deh = sm_user.getDefaultHandler(sm_user.getServices()); StorageUtils.processString(xml, deh); return deh.getEntity(); } else { Document doc = StorageUtils.readDocumentFromString(xml);
/** * Load the Xml Document */ protected Document load() { return StorageUtils.readDocument(m_fileStoragePath); }
/** * flush */ protected void flush() { Document doc = createDocument(); StorageUtils.writeDocument(doc, m_fileStoragePath); }
public Edit putResource(String id, Object[] others) { // create one with just the id, and perhaps some other fields as well Entity entry = m_user.newResource(null, id, others); // form the XML and SQL for the insert Document doc = StorageUtils.createDocument(); entry.toXml(doc, new Stack()); String xml = StorageUtils.writeDocumentToString(doc); String statement = // singleStorageSql. "insert into " + m_resourceTableName + insertFields(m_resourceTableIdField, m_resourceTableOtherFields, "XML") + " values ( ?, " + valuesParams(m_resourceTableOtherFields) + " ? )"; Object[] flds = m_user.storageFields(entry); if (flds == null) flds = new Object[0]; Object[] fields = new Object[flds.length + 2]; System.arraycopy(flds, 0, fields, 1, flds.length); fields[0] = caseId(entry.getId()); fields[fields.length - 1] = xml; // process the insert boolean ok = m_sql.dbWrite(statement, fields); // if this failed, assume a key conflict (i.e. id in use) if (!ok) return null; // now get a lock on the record for edit Edit edit = editResource(id); if (edit == null) { log.warn("putResource(): didn't get a lock!"); return null; } return edit; }
DefaultEntityHandler deh = sm_user.getDefaultHandler(sm_user .getServices()); StorageUtils.processString(xml, deh); return deh.getEntity(); Document doc = StorageUtils.readDocumentFromString(xml);
+ StorageUtils.escapeSql(caseId(id)) + "' )" + " for update nowait"; StringBuilder result = new StringBuilder(); Connection lock = m_sql.dbReadLock(statement, result);
/** * Read a DOM Document from xml in a string. * * @param in * The string containing the XML * @return A new DOM Document with the xml contents. */ public static Document readDocumentFromString(String in) { try { DocumentBuilder docBuilder = getDocumentBuilder(); InputSource inputSource = new InputSource(new StringReader(in)); Document doc = docBuilder.parse(inputSource); return doc; } catch (Exception any) { log.warn("readDocumentFromString: " + any.toString()); return null; } }
/** * Process a string of XML using SAX and a default handler * @param in * @param dh * @throws SAXException * @throws IOException */ public static void processString( String in, DefaultHandler dh ) throws SAXException, IOException { Reader r = new StringReader(in); processReader(r,dh); r.close(); }
Document doc = StorageUtils.createDocument(); Stack stack = new Stack(); Element root = doc.createElement(m_rootTagName);
public Edit putResource(String id, Object[] others) { // create one with just the id, and perhaps some other fields as well Entity entry = m_user.newResource(null, id, others); // form the XML and SQL for the insert Document doc = StorageUtils.createDocument(); entry.toXml(doc, new Stack()); String xml = StorageUtils.writeDocumentToString(doc); String statement = // singleStorageSql. "insert into " + m_resourceTableName + insertFields(m_resourceTableIdField, m_resourceTableOtherFields, "XML") + " values ( ?, " + valuesParams(m_resourceTableOtherFields) + " ? )"; Object[] flds = m_user.storageFields(entry); if (flds == null) flds = new Object[0]; Object[] fields = new Object[flds.length + 2]; System.arraycopy(flds, 0, fields, 1, flds.length); fields[0] = caseId(entry.getId()); fields[fields.length - 1] = xml; // process the insert boolean ok = m_sql.dbWrite(statement, fields); // if this failed, assume a key conflict (i.e. id in use) if (!ok) return null; // now get a lock on the record for edit Edit edit = editResource(id); if (edit == null) { log.warn("putResource(): didn't get a lock!"); return null; } return edit; }