@SuppressWarnings("unchecked")
@Override
void resetChildrenPermissionReferences(Structure structure) throws DotDataException {
ContentletAPI contAPI = APILocator.getContentletAPI();
ContentletIndexAPI indexAPI=new ESContentletIndexAPI();
DotConnect dc = new DotConnect();
dc.setSQL(deleteContentReferencesByStructureSQL);
dc.addParam(structure.getPermissionId());
dc.loadResult();
final int limit=500;
int offset=0;
List<Contentlet> contentlets;
do {
String query="structurename:"+structure.getVelocityVarName();
try {
contentlets=contAPI.search(query, limit, offset, "identifier", APILocator.getUserAPI().getSystemUser(), false);
} catch (DotSecurityException e) {
throw new RuntimeException(e);
}
BulkRequestBuilder bulk=new ESClient().getClient().prepareBulk();
for(Contentlet cont : contentlets) {
permissionCache.remove(cont.getPermissionId());
indexAPI.addContentToIndex(cont, false, true, true, bulk);
}
if(bulk.numberOfActions()>0)
bulk.execute().actionGet();
offset=offset+limit;