use of com.enonic.xp.node.NodeStorageException in project xp by enonic.
the class StorageDaoImpl method delete.
@Override
public void delete(final DeleteRequests requests) {
final StorageSource settings = requests.getSettings();
for (final String id : requests.getIds()) {
try {
final org.elasticsearch.action.delete.DeleteRequest request = new DeleteRequestBuilder(this.client, DeleteAction.INSTANCE).setIndex(settings.getStorageName().getName()).setType(settings.getStorageType().getName()).setRefresh(requests.isForceRefresh()).setId(id).setRouting(// TODO Java10
id).request();
this.client.delete(request).actionGet(requests.getTimeoutAsString());
} catch (ClusterBlockException e) {
throw new NodeStorageException("Cannot delete node " + id + ", Repository in 'READ-ONLY mode'");
} catch (Exception e) {
throw new NodeStorageException("Cannot delete node " + id, e);
}
}
}
use of com.enonic.xp.node.NodeStorageException in project xp by enonic.
the class StorageDaoImpl method delete.
@Override
public boolean delete(final DeleteRequest request) {
final StorageSource settings = request.getSettings();
final String id = request.getId();
final DeleteRequestBuilder builder = new DeleteRequestBuilder(this.client, DeleteAction.INSTANCE).setId(id).setIndex(settings.getStorageName().getName()).setType(settings.getStorageType().getName()).setRefresh(request.isForceRefresh());
final DeleteResponse deleteResponse;
try {
deleteResponse = this.client.delete(builder.request()).actionGet(request.getTimeoutAsString());
} catch (ClusterBlockException e) {
throw new NodeStorageException("Cannot delete node " + id + ", Repository in 'READ-ONLY mode'");
} catch (Exception e) {
throw new NodeStorageException("Cannot delete node " + id, e);
}
return deleteResponse.isFound();
}
use of com.enonic.xp.node.NodeStorageException in project xp by enonic.
the class DeleteNodeByIdCommandTest_error_handling method delete_children_first.
@Test
public void delete_children_first() throws Exception {
final Node n1 = createNode(NodePath.ROOT, "n1");
final Node n2 = createNode(NodePath.ROOT, "n2");
final Node n1_1 = createNode(n1.path(), "n1_1");
final Node n1_1_1 = createNode(n1_1.path(), "n1_1_1");
final Node n1_1_1_1 = createNode(n1_1_1.path(), "n1_1_1_1");
refresh();
this.storageDao.setClient(new FailDeleteOnIdsProxy(client, NodeIds.from(n1_1.id())));
try {
doDeleteNode(n1.id());
} catch (NodeStorageException e) {
// expected
}
assertNull(getNode(n1_1_1_1.id()));
assertNull(getNode(n1_1_1.id()));
assertNotNull(getNode(n1_1.id()));
assertNotNull(getNode(n1.id()));
assertNotNull(getNode(n2.id()));
}
Aggregations