* default a new, unique ID is returned.
* @return Returns an ID.
*/
@SupportsOption(options = { ID.class })
public String uniqueID(Option... options) {
final ID id = Options.$(this.commonCore, options).ID();
if(id == ID.SYSTEM || id == ID.USER) {
try {
// System nodes apparently fail for Lion when syncing() (see Issue #15).
final Preferences node = id == ID.SYSTEM ? Preferences.systemNodeForPackage(getClass()) : Preferences.userNodeForPackage(getClass());
final String rval = node.get("system.id", "UNAVAILABLE");
if("UNAVAILABLE".equals(rval)) {
String newid = UUID.randomUUID().toString();
node.put("system.id", newid);
node.sync();
return newid;
}
return rval;
} catch(Exception e) {
Options.$(this.commonCore, options).failure(null, e, "uniqueid:create", "Error getting the ID " + id.getClass() + " (on Lion this might be a bug).");
return "UNAVAILABLE";
}
}
return UUID.randomUUID().toString();