public void doSave() {


        UserBean userBean = (UserBean) BeanHelper.getBean("userBean");
        //load unitate into hashmap
        List<Unitate> unitateList = userBean.getUser().getSirues().getUnitateList();
        HashMap<String, Long> siruesMap = new HashMap<>();
        HashMap<Long, Integer> countMap = new HashMap<>();
        for (int i = 0; i < unitateList.size(); i++) {
            siruesMap.put(unitateList.get(i).getNumeRo(), unitateList.get(i).getSirues());
            countMap.put(unitateList.get(i).getSirues(), 0);
        }

        //loop over imageList
        for (int i = 0; i < imageList.size(); i++) {
            SchoolImage schoolImage = imageList.get(i);
            if (!schoolImage.getDestination().equals(SchoolImage.DESTINATION_UNUSED)) {
                //if used whe check usage
                File oldName = new File(FILE_PREFIX + "/" + schoolImage.getFileName());
                File newName;
                Long sirues = siruesMap.get(schoolImage.getUnitatea());
                if (schoolImage.getDestination().equals(SchoolImage.DESTINATION_FACADE)) {
                    //facade, only 1 image
                    newName = new File(FILE_PREFIX + "/" + sirues + "_fata.jpeg");
                } else {
                    //class, we keep count
                    newName = new File(FILE_PREFIX + "/" + sirues + "_" + countMap.get(sirues) + ".jpeg");
                    countMap.put(sirues, countMap.get(sirues) + 1);
                }
                try {
                    if (newName.exists()) {
                        newName.delete();
                    }
                    if (oldName.renameTo(newName)) {
                        System.out.println("Saved as: " + newName.getAbsolutePath());
                    } else {
                        //Rename failed, making copy

                        //copy file with Java 7 API
                        Path oldPath = Paths.get(oldName.getAbsolutePath());
                        Path newPath = Paths.get(newName.getAbsolutePath());
                        Files.copy(oldPath, newPath, StandardCopyOption.REPLACE_EXISTING);

                        //copy file
                        /*FileOutputStream fileOutputStream = new FileOutputStream(newName);
                         byte[] buffer = new byte[BUFFER_SIZE];
                         int bulk;
                         InputStream inputStream = new FileInputStream(oldName);
                         while (true) {
                         bulk = inputStream.read(buffer);
                         if (bulk < 0) {
                         break;
                         }
                         fileOutputStream.write(buffer, 0, bulk);
                         fileOutputStream.flush();
                         }
                         fileOutputStream.close();
                         inputStream.close();*/
                        System.out.println("Copy to: " + newName.getAbsolutePath() + " scuccess!");
                    }
                } catch (Exception ex) {
                    System.out.println(ex);
                }
            }
        }

        imageList.clear();
    }