private String slideShowAll(HttpSession session, HttpServletRequest request) {
try {
String strIds = (String) request.getParameter("ids");
String[] ids = strIds.split(",");
SpecialTube spTube = SpecialTubeModel.getByType("slide", false);
if (spTube == null) {
spTube = new SpecialTube();
spTube.setId(IdUniqueHelper.getId());
spTube.setType("slide");
SpecialTubeModel.insert(spTube);
}
List<String> listSlideTubeId = spTube.getListTubeId();
for (int i = 0; i < ids.length; i++) {
if (!ids[i].isEmpty()) {
Tube tube = TubeModel.getById(ids[i], false);
if (tube != null) {
if (!listSlideTubeId.contains(tube.getId())) {
if (listSlideTubeId.size() == 8) {
listSlideTubeId.remove(0);
}
listSlideTubeId.add(tube.getId());
} else {
for (int j = 0; j < listSlideTubeId.size(); j++) {
if (listSlideTubeId.get(j).equals(tube.getId())) {
listSlideTubeId.remove(j);
break;
}
}
listSlideTubeId.add(tube.getId());
}
}
}
}
spTube.setListTubeId(listSlideTubeId);
SpecialTubeModel.insert(spTube);
return "";
} catch (Exception e) {
return "Action fails ! Please try again !";
}