use of com.rebuild.core.service.general.recyclebin.RecycleStore in project rebuild by getrebuild.
the class GeneralEntityService method delete.
@Override
public int delete(ID record, String[] cascades) {
final ID currentUser = UserContextHolder.getUser();
final RecycleStore recycleBin = useRecycleStore(record);
this.deleteInternal(record);
int affected = 1;
Map<String, Set<ID>> recordsOfCascaded = getCascadedRecords(record, cascades, BizzPermission.DELETE);
for (Map.Entry<String, Set<ID>> e : recordsOfCascaded.entrySet()) {
if (log.isDebugEnabled()) {
log.debug("Cascade delete - " + e.getKey() + " > " + e.getValue());
}
for (ID id : e.getValue()) {
if (Application.getPrivilegesManager().allowDelete(currentUser, id)) {
if (recycleBin != null)
recycleBin.add(id, record);
int deleted = 0;
try {
deleted = this.deleteInternal(id);
} catch (DataSpecificationException ex) {
log.warn("Cannot delete : " + id + " Ex : " + ex);
} finally {
if (deleted > 0) {
affected++;
} else if (recycleBin != null) {
// If not delete
recycleBin.removeLast();
}
}
} else {
log.warn("No have privileges to DELETE : " + currentUser + " > " + id);
}
}
}
if (recycleBin != null)
recycleBin.store();
return affected;
}
use of com.rebuild.core.service.general.recyclebin.RecycleStore in project rebuild by getrebuild.
the class ProjectTaskService method delete.
@Override
public int delete(ID taskId) {
final ID user = UserContextHolder.getUser();
if (!ProjectHelper.isManageable(taskId, user))
throw new OperationDeniedException();
// 先删评论
Object[][] comments = Application.createQueryNoFilter("select commentId from ProjectTaskComment where taskId = ?").setParameter(1, taskId).array();
for (Object[] c : comments) {
Application.getBean(ProjectCommentService.class).delete((ID) c[0]);
}
// 只有任务本身可以恢复
final RecycleStore recycleBin = useRecycleStore(taskId);
int d = super.delete(taskId);
ProjectManager.instance.clean(taskId);
if (recycleBin != null)
recycleBin.store();
return d;
}
use of com.rebuild.core.service.general.recyclebin.RecycleStore in project rebuild by getrebuild.
the class ObservableService method useRecycleStore.
/**
* 使用回收站
*
* @param recordId
* @return 返回 null 表示没开启
*/
protected RecycleStore useRecycleStore(ID recordId) {
final ID currentUser = UserContextHolder.getUser();
RecycleStore recycleBin = null;
if (RecycleBinCleanerJob.isEnableRecycleBin()) {
recycleBin = new RecycleStore(currentUser);
} else {
log.warn("RecycleBin inactivated! DELETE {} by {}", recordId, currentUser);
}
if (recycleBin != null)
recycleBin.add(recordId);
return recycleBin;
}
use of com.rebuild.core.service.general.recyclebin.RecycleStore in project rebuild by getrebuild.
the class FeedsService method delete.
@Override
public int delete(ID recordId) {
// 先删评论
Object[][] comments = Application.createQueryNoFilter("select commentId from FeedsComment where feedsId = ?").setParameter(1, recordId).array();
for (Object[] c : comments) {
Application.getBean(FeedsCommentService.class).delete((ID) c[0]);
}
// 只有动态本身可以恢复
final RecycleStore recycleBin = useRecycleStore(recordId);
int d = super.delete(recordId);
if (recycleBin != null)
recycleBin.store();
return d;
}
Aggregations