protected List<Contentlet> findContentlets(List<String> inodes) throws DotDataException, DotStateException, DotSecurityException {
ArrayList<Contentlet> result = new ArrayList<Contentlet>();
ArrayList<String> inodesNotFound = new ArrayList<String>();
for (String i : inodes) {
Contentlet c = cc.get(i);
if(c != null && InodeUtils.isSet(c.getInode())){
result.add(c);
} else {
inodesNotFound.add(i);
}
}
if(inodesNotFound.isEmpty()){
return result;
}
final String hql = "select {contentlet.*} from contentlet join inode contentlet_1_ " +
"on contentlet_1_.inode = contentlet.inode and contentlet_1_.type = 'contentlet' where contentlet.inode in ('";
for(int init=0; init < inodesNotFound.size(); init+=200) {
int end = Math.min(init + 200, inodesNotFound.size());
HibernateUtil hu = new HibernateUtil(com.dotmarketing.portlets.contentlet.business.Contentlet.class);
hu.setSQLQuery( hql + StringUtils.join(inodesNotFound.subList(init, end), "','") + "')");
List<com.dotmarketing.portlets.contentlet.business.Contentlet> fatties = hu.list();
for (com.dotmarketing.portlets.contentlet.business.Contentlet fatty : fatties) {
Contentlet con = convertFatContentletToContentlet(fatty);
result.add(con);
cc.add(con.getInode(), con);
}
HibernateUtil.getSession().clear();
}
return result;