* {@inheritDoc}
*/
@Override
- public boolean isLocalSone(Sone sone) throws DatabaseException {
- Validation.begin().isNotNull("Sone", sone).check();
- return isLocalSone(sone.getId());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isLocalSone(String id) throws DatabaseException {
- Validation.begin().isNotNull("Sone ID", id).check();
- synchronized (localSones) {
- return localSones.containsKey(id);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRemoteSone(Sone sone) throws DatabaseException {
- Validation.begin().isNotNull("Sone", sone).check();
- return isRemoteSone(sone.getId());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRemoteSone(String id) throws DatabaseException {
- Validation.begin().isNotNull("Sone ID", id).check();
- synchronized (remoteSones) {
- return remoteSones.containsKey(id);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public Sone getSone(String id, boolean create) throws DatabaseException {
- if (isLocalSone(id)) {
+ if (getLocalSone(id, false) != null) {
return getLocalSone(id, create);
}
return getRemoteSone(id, create);
Validation.begin().isNotNull("Sone ID", id).check();
synchronized (localSones) {
if (!localSones.containsKey(id) && create) {
- localSones.put(id, new Sone(id));
+ localSones.put(id, new Sone(id, true));
}
return localSones.get(id);
}
Validation.begin().isNotNull("Sone ID", id).check();
synchronized (remoteSones) {
if (!remoteSones.containsKey(id) && create) {
- remoteSones.put(id, new Sone(id));
+ remoteSones.put(id, new Sone(id, false));
}
return remoteSones.get(id);
}
*/
@Override
public void saveSone(Sone sone) throws DatabaseException {
- if (isLocalSone(sone)) {
+ if (sone.isLocal()) {
synchronized (localSones) {
localSones.put(sone.getId(), sone);
}
*/
@Override
public void removeSone(Sone sone) throws DatabaseException {
- Map<String, Sone> sones = isLocalSone(sone) ? localSones : remoteSones;
+ Map<String, Sone> sones = sone.isLocal() ? localSones : remoteSones;
synchronized (sones) {
sones.remove(sone.getId());
}
*/
@Override
public void removeSone(String id) throws DatabaseException {
- Map<String, Sone> sones = isLocalSone(id) ? localSones : remoteSones;
+ Map<String, Sone> sones = ((getSone(id, false) != null) && getSone(id, false).isLocal()) ? localSones : remoteSones;
synchronized (sones) {
sones.remove(id);
}