public void delete(int albumId, String uploadFilePath) { List<Album> albumList = new ArrayList<Album>(); Album parentAlbum = new Album(); if (albumId == 0) parentAlbum.setAlbumId(Integer.valueOf(albumId)); else { parentAlbum = selectByPrimaryKey(Integer.valueOf(albumId)); } getAlbumList(parentAlbum, albumList); for (Album album : albumList) { if ("1".equals(album.getIsleaf())) { PictureWithBLOBs paramPicture = new PictureWithBLOBs(); paramPicture.setAlbumId(album.getAlbumId()); paramPicture.setDelflag("1"); List<Picture> pictureList = this.pictureService.selectByCriteria(paramPicture); if ((pictureList != null) && (pictureList.size() > 0)) { for (Picture picture : pictureList) { File lfile = new File(uploadFilePath + "/" + picture.getLpath()); if (lfile != null) { lfile.delete(); } File sfile = new File(uploadFilePath + "/" + "thumbnail" + "/" + picture.getSpath()); if (sfile != null) { sfile.delete(); } } } } this.albumDao.deleteByPrimaryKey(album.getAlbumId().intValue()); } }
private void getAlbumList(Album parentAlbum, List<Album> albumList) { albumList.add(parentAlbum); Album paramAlbum = new Album(); paramAlbum.setParentId(parentAlbum.getAlbumId()); List newAlbumList = selectByCriteria(paramAlbum); if (newAlbumList != null) for (int i = 0; i < newAlbumList.size(); i++) getAlbumList((Album) newAlbumList.get(i), albumList); }