private XMLSerializableAdapter groupsCol;
private XMLSerializableAdapter contentCol;
public String getMachineID() {
if ( machineID == null ) {
Transaction tx = new Transaction();
try {
Collection sysCol = collection.getSystemCollection();
Collection cfgCol = sysCol.getCollection(SystemCollection.CONFIGS);
DOMAdapter domAdapter = new DOMAdapter(cfgCol);
Document doc = domAdapter.getDocument(tx, SYNCID_XML);
if ( doc != null ) {
Element elem = doc.getDocumentElement();
machineID = elem.getAttribute(ID);
}
else {
machineID = cfgCol.createNewOID().toString();
doc = DOMHelper.newDocument();
Element elem = doc.createElement(SYNC);
doc.appendChild(elem);
elem.setAttribute(ID, machineID);
domAdapter.setDocument(tx, SYNCID_XML, doc);
}
}
catch ( Exception e ) {
try {
tx.cancel();
}
catch ( DBException ex ) {
ex.printStackTrace(System.err);
}
// If this doesn't work, something is VERY wrong
e.printStackTrace(System.err);
machineID = collection.createNewOID().toString();
}
finally {
if ( tx.getStatus() == Transaction.ACTIVE ) {
try {
tx.commit();
}
catch ( DBException e ) {
e.printStackTrace(System.err);
}
}