/** * Deletes the container for the index in which it should reside. * * @param container * @param branchUuid * @param type * @return */ private Completable deleteContainer(NodeGraphFieldContainer container, String branchUuid, ContainerType type) { String projectUuid = container.getParentNode().getProject().getUuid(); return searchProvider.deleteDocument(container.getIndexName(projectUuid, branchUuid, type), container.getDocumentId()); }
/** * We need to handle permission update requests for nodes here since the action must affect multiple documents in multiple indices . */ @Override public Observable<UpdateBulkEntry> updatePermissionForBulk(UpdateDocumentEntry entry) { String uuid = entry.getElementUuid(); Node node = getRootVertex().findByUuid(uuid); if (node == null) { throw error(INTERNAL_SERVER_ERROR, "error_element_for_document_type_not_found", uuid, DEFAULT_TYPE); } else { Project project = node.getProject(); List<UpdateBulkEntry> entries = new ArrayList<>(); // Determine which documents need to be updated. The node could have multiple documents in various indices. for (Branch branch : project.getBranchRoot().findAll()) { for (ContainerType type : Arrays.asList(DRAFT, PUBLISHED)) { JsonObject json = getTransformer().toPermissionPartial(node, type); for (NodeGraphFieldContainer container : node.getGraphFieldContainersIt(branch, type)) { String indexName = container.getIndexName(project.getUuid(), branch.getUuid(), type); String documentId = container.getDocumentId(); entries.add(new UpdateBulkEntry(indexName, documentId, json, true)); } } } return Observable.fromIterable(entries); } }