/** * Update title and description of a document * * @param Docman_Item $item The item */ public function updateDocument(Docman_Item $item) { $update_data = $this->client->initializeSetterData(); $update_data = $this->client->appendSetterData($update_data, 'title', $item->getTitle()); $update_data = $this->client->appendSetterData($update_data, 'description', $item->getDescription()); $this->client->update($item->getid(), $update_data); }
private function indexOrUpdate($project_id, $wiki_page_id, $data) { try { $this->client->getIndexedElement($project_id, $wiki_page_id); $this->client->update($project_id, $wiki_page_id, $data); } catch (ElasticSearch_ElementNotIndexed $exception) { $this->client->index($project_id, $wiki_page_id, $data); return; } }
/** * Update title and description if they've changed * $params are kept as array to be compliant with others events, * but we merely need event objects * * @param array $params */ public function updateDocument($params) { $item = $params['item']; $new_data = $params['new']; $update_data = array('script' => '', 'params' => array()); $updated = false; if ($this->titleUpdated($new_data['title'], $item)) { $update_data = $this->client->buildSetterData($update_data, 'title', $new_data['title']); $updated = true; } if ($this->descriptionUpdated($new_data, $item)) { $update_data = $this->client->buildSetterData($update_data, 'description', $new_data['description']); $updated = true; } if ($updated) { $this->client->update($item->getid(), $update_data); } }
/** * Update title and description if they've changed * $params are kept as array to be compliant with others events, * but we merely need event objects * * @param array $params */ public function updateDocument($params) { $item = $params['item']; $new_data = $params['new']; $update_data = $this->client->initializeSetterData(); $updated = false; if ($this->titleUpdated($new_data['title'], $item)) { $update_data = $this->client->appendSetterData($update_data, 'title', $new_data['title']); $updated = true; } if ($this->descriptionUpdated($new_data, $item)) { $update_data = $this->client->appendSetterData($update_data, 'description', $new_data['description']); $updated = true; } if ($updated) { $this->client->update($item->getid(), $update_data); } }
/** * Index the new permissions of a document * * @param Docman_Item the document * @throws FullTextSearchDocmanIndexFileTooBigException */ public function updatePermissions(Docman_Item $item) { $this->logger->debug('update permissions of document #' . $item->getId() . ' and its children'); $item_factory = $this->getDocmanItemFactory($item); $items = array_merge(array($item), $item_factory->getAllChildrenFromParent($item)); foreach ($items as $item_to_index) { try { $this->client->getIndexedElement($item->getGroupId(), $item->getId()); $this->logger->debug('update permissions of item #' . $item_to_index->getId()); $update_data = array(); $this->request_data_factory->setUpdatedData($update_data, 'permissions', $this->request_data_factory->getCurrentPermissions($item)); $this->client->update($item_to_index->getGroupId(), $item_to_index->getId(), $update_data); } catch (ElasticSearch_ElementNotIndexed $exception) { $this->indexNonexistantDocument($item_to_index); return; } } }