/** {@inheritDoc} */ @Override public void update(Observable userDao, Object object) { LogbookEntry newEntry = null; if (this.is(object, User.class)) { User user = (User) object; if (user.hasBeenAnonymized()) { newEntry = this.getEntryForUserAnonymized(user.getUsernameBeforeAnonym()); } else if (user.hasJustBeenInserted()) { // a new user was inserted newEntry = this.getEntryForUserNew(user); } else if (user.hasJustBeenDeleted()) { newEntry = this.getEntryForUserDeleted(user); } else { User old = FamDaoProxy.userDao().getUserFromUsername(user.getUsername()); newEntry = this.getEntryForUserUpdate(old, user); } } else if (this.is(object, ContactDetail.class)) { ContactDetail cd = (ContactDetail) object; newEntry = this.getEntryForContactDetails(cd); } if (newEntry != null) { newEntry.insert(); } else { FamLog.error("observed an unknown event: " + object.getClass(), 201403061006l); } }
/** {@inheritDoc}} */ @Override public JSONObject getRealSoaActivationPageDocument(String docId) { JSONObject result = null; Response responseForRealSoaDocument = FamCouchDBDao.response(docId); if (responseForRealSoaDocument.isOk()) { try { result = new JSONObject(responseForRealSoaDocument.getContentAsString()); } catch (JSONException e) { FamLog.exception(e, 201205041026l); } } return result; }
private LogbookEntry getEntryForUserUpdate(User oldUser, User newUser) { LogbookEntry result = this.getNewBaseEntry(); result.setHeadline("Update user: "******"please report error 201402061143"); } result.setContent(StringUtils.join(messages.toArray(), "\r\n")); // FIXME check delimiter return result; }