@SuppressWarnings("ReassignmentInjectVariable") public Secure(DataManager dataManager, Transactions transactions) { this.dataManager = dataManager.secure(); this.transactions = transactions; } }
@Override public InputStream downloadFile(FileDescriptor fileDescriptor) throws FileStorageException { FileDescriptor descriptor; try { // FileDescriptor must be available for the current user and be non deleted descriptor = dataManager.secure().reload(fileDescriptor, View.LOCAL); } catch (EntityAccessException e) { throw new FileStorageException(FileStorageException.Type.FILE_NOT_FOUND, fileDescriptor.getName(), e); } return fileStorage.openStream(descriptor); } }
protected List<Entity> loadEntities(List<Object> entityIds, MetaClass metaClass) { MetaProperty primaryKeyForFts = manager.getPrimaryKeyPropertyForFts(metaClass); List<Entity> result = new ArrayList<>(); for (List<Object> partition : Lists.partition(entityIds, ftsConfig.getLoadSize())) { List<Entity<Object>> partitionResult = dataManager.secure() .load(metaClass.getJavaClass()) .view(View.MINIMAL) .query(String.format("select e from %s e where e.%s in :ids", metaClass.getName(), primaryKeyForFts.getName())) .parameter("ids", partition) .list(); result.addAll(partitionResult); } return result; } }
protected List<Entity> loadItemsWithDirectKey(LoadDescriptor ld) { LoadContext.Query query = new LoadContext.Query( String.format("select e from %s e where e.%s in :ids", ld.getMetaClass(), metadataTools.getPrimaryKeyName(ld.getMetaClass()))); List<Object> ids = ld.getSelectedItems().stream() .map(Entity::getId) .collect(Collectors.toList()); query.setParameter("ids", ids); LoadContext<Entity> lc = new LoadContext<>(ld.getMetaClass()); lc.setSoftDeletion(false); lc.setQuery(query); lc.setView(ld.getView()); lc.setLoadDynamicAttributes(ld.isLoadDynamicAttributes()); return dataManager.secure().loadList(lc); } }
@Override public void changeGroupParent(UUID groupId, UUID newParentId) { checkUpdatePermission(Group.class); DataManager dataManager = this.dataManager.secure(); Group group = dataManager.load(LoadContext.create(Group.class) .setId(groupId) .setView(GROUP_COPY_VIEW)); LoadContext<Group> context = LoadContext.create(Group.class) .setId(newParentId) .setView(GROUP_COPY_VIEW); Group newParent = newParentId != null ? dataManager.load(context) : null; if (group != null) { group.setParent(newParent); } dataManager.commit(group); }