use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class TestRangerBizUtil method testGetMObject_NoObjId.
@Test
public void testGetMObject_NoObjId() {
XXDBBase mObjChk = rangerBizUtil.getMObject(RangerCommonEnums.CLASS_TYPE_USER_PROFILE, null);
Assert.assertNull(mObjChk);
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class JPABeanCallbacks method onPreUpdate.
// @PostPersist
// void onPostPersist(Object o) {
// if (o != null && o instanceof MBase) {
// MBase entity = (MBase) o;
// if (logger.isDebugEnabled()) {
// logger.debug("DBChange.create:class=" + o.getClass().getName()
// + entity.getId());
// }
//
// }
// }
// @PostLoad void onPostLoad(Object o) {}
@PreUpdate
void onPreUpdate(Object o) {
try {
if (o != null && o instanceof XXDBBase) {
XXDBBase entity = (XXDBBase) o;
entity.setUpdateTime(DateUtil.getUTCDate());
}
} catch (Throwable t) {
logger.error(t);
}
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class JPABeanCallbacks method onPrePersist.
@PrePersist
void onPrePersist(Object o) {
try {
if (o != null && o instanceof XXDBBase) {
XXDBBase entity = (XXDBBase) o;
entity.setUpdateTime(DateUtil.getUTCDate());
RangerSecurityContext context = RangerContextHolder.getSecurityContext();
if (context != null) {
UserSessionBase userSession = context.getUserSession();
if (userSession != null) {
entity.setAddedByUserId(userSession.getUserId());
entity.setUpdatedByUserId(userSession.getUserId());
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Security context not found for this request. obj=" + o, new Throwable());
}
}
}
} catch (Throwable t) {
logger.error(t);
}
}
Aggregations