Closes #99: Update /app/batch/clean_storage & /app/batch/acl_tags

This commit is contained in:
jendib 2016-05-09 19:11:44 +02:00
parent 4a512af178
commit b9cd113dc0
No known key found for this signature in database
GPG Key ID: 06EE7F699579166F
2 changed files with 22 additions and 19 deletions

View File

@ -209,7 +209,8 @@ public class AppResource extends BaseResource {
sb.append(" left join T_FILE f on f.FIL_ID_C = al.LOG_IDENTITY_C and f.FIL_DELETEDATE_D is null ");
sb.append(" left join T_TAG t on t.TAG_ID_C = al.LOG_IDENTITY_C and t.TAG_DELETEDATE_D is null ");
sb.append(" left join T_USER u on u.USE_ID_C = al.LOG_IDENTITY_C and u.USE_DELETEDATE_D is null ");
sb.append(" where d.DOC_ID_C is null and a.ACL_ID_C is null and c.COM_ID_C is null and f.FIL_ID_C is null and t.TAG_ID_C is null and u.USE_ID_C is null)");
sb.append(" left join T_GROUP g on g.GRP_ID_C = al.LOG_IDENTITY_C and g.GRP_DELETEDATE_D is null ");
sb.append(" where d.DOC_ID_C is null and a.ACL_ID_C is null and c.COM_ID_C is null and f.FIL_ID_C is null and t.TAG_ID_C is null and u.USE_ID_C is null and g.GRP_ID_C is null)");
Query q = em.createNativeQuery(sb.toString());
log.info("Deleting {} orphan audit logs", q.executeUpdate());
@ -217,8 +218,10 @@ public class AppResource extends BaseResource {
sb = new StringBuilder("update T_ACL a set ACL_DELETEDATE_D = :dateNow where a.ACL_ID_C in (select a.ACL_ID_C from T_ACL a ");
sb.append(" left join T_SHARE s on s.SHA_ID_C = a.ACL_TARGETID_C ");
sb.append(" left join T_USER u on u.USE_ID_C = a.ACL_TARGETID_C ");
sb.append(" left join T_GROUP g on g.GRP_ID_C = a.ACL_TARGETID_C ");
sb.append(" left join T_DOCUMENT d on d.DOC_ID_C = a.ACL_SOURCEID_C ");
sb.append(" where s.SHA_ID_C is null and u.USE_ID_C is null or d.DOC_ID_C is null)");
sb.append(" left join T_TAG t on t.TAG_ID_C = a.ACL_SOURCEID_C ");
sb.append(" where s.SHA_ID_C is null and u.USE_ID_C is null and g.GRP_ID_C is null or d.DOC_ID_C is null and t.TAG_ID_C is null)");
q = em.createNativeQuery(sb.toString());
q.setParameter("dateNow", new Date());
log.info("Deleting {} orphan ACLs", q.executeUpdate());
@ -262,6 +265,7 @@ public class AppResource extends BaseResource {
log.info("Deleting {} soft deleted files", em.createQuery("delete File f where f.deleteDate is not null").executeUpdate());
log.info("Deleting {} soft deleted documents", em.createQuery("delete Document d where d.deleteDate is not null").executeUpdate());
log.info("Deleting {} soft deleted users", em.createQuery("delete User u where u.deleteDate is not null").executeUpdate());
log.info("Deleting {} soft deleted groups", em.createQuery("delete Group g where g.deleteDate is not null").executeUpdate());
// Always return OK
JsonObjectBuilder response = Json.createObjectBuilder()
@ -344,10 +348,8 @@ public class AppResource extends BaseResource {
AclDao aclDao = new AclDao();
List<AclDto> aclDtoList = aclDao.getBySourceId(tagDto.getId());
String userId = userDao.getActiveByUsername(tagDto.getCreator()).getId();
for (AclDto aclDto : aclDtoList) {
aclDao.delete(aclDto.getSourceId(), aclDto.getPerm(), aclDto.getTargetId(), userId);
}
if (aclDtoList.size() == 0) {
// Create read ACL
Acl acl = new Acl();
acl.setPerm(PermType.READ);
@ -362,6 +364,7 @@ public class AppResource extends BaseResource {
acl.setTargetId(userId);
aclDao.create(acl, userId);
}
}
// Always return OK
JsonObjectBuilder response = Json.createObjectBuilder()

View File

@ -29,7 +29,7 @@
<option ng-repeat="tag0 in tags"
ng-if="tag0.id != tag.id"
ng-selected="tag.parent == tag0.id"
value="{{ tag0.id }}">Parent: {{ tag0.name }}</option>
value="{{ tag0.id }}">{{ tag0.name }}</option>
</select>
</div>
</div>