Example usage for org.apache.commons.io FileUtils copyFileToDirectory

List of usage examples for org.apache.commons.io FileUtils copyFileToDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils copyFileToDirectory.

Prototype

public static void copyFileToDirectory(File srcFile, File destDir) throws IOException 

Source Link

Document

Copies a file to a directory preserving the file date.

Usage

From source file:elaborate.editor.publish.PublishTask.java

private void deploy(File war) {
    File destDir = new File(config.getSetting(PUBLICATION_TOMCAT_WEBAPPDIR));
    try {/*from  ww w.j a  v a 2  s . c  om*/
        FileUtils.copyFileToDirectory(war, destDir);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

protected void restoreConfigData(String fileName) {
    if (doneRestore)
        return;/*from  w  w  w  .  ja  v  a  2 s .c o m*/
    String filePath = productConfDirPath + fileName;
    File srcDir = new File(".");
    File srcFile = null, destDir = null;
    try {
        String srcFilePath = srcDir.getCanonicalPath() + File.separator + fileName;
        srcFile = new File(srcFilePath);
        destDir = new File(filePath);
        if (destDir.exists())
            destDir.delete();
        destDir = new File(productConfDirPath);
        FileUtils.copyFileToDirectory(srcFile, destDir);
        Log.getLogWriter().info(
                "Done restoring " + fileName + " file from " + srcFile.getAbsolutePath() + " to " + destDir);
    } catch (IOException e) {
        throw new TestException(
                "Error occurred while copying data from file: " + srcFile + "\n " + e.getMessage());
    }
    doneRestore = true;
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

public static synchronized void HydraTask_copyDiskFiles() {
    if (diskDirExists)
        return;/*w  w w .ja  va  2s .  c o  m*/
    else {
        String dirName = snappyTest.generateLogDirName();
        File destDir = new File(dirName);
        String diskDirName = dirName.substring(0, dirName.lastIndexOf("_")) + "_disk";
        File dir = new File(diskDirName);
        for (File srcFile : dir.listFiles()) {
            try {
                if (srcFile.isDirectory()) {
                    FileUtils.copyDirectoryToDirectory(srcFile, destDir);
                    Log.getLogWriter()
                            .info("Done copying diskDirFile directory from: " + srcFile + " to " + destDir);
                } else {
                    FileUtils.copyFileToDirectory(srcFile, destDir);
                    Log.getLogWriter().info("Done copying diskDirFile from: " + srcFile + " to " + destDir);
                }
            } catch (IOException e) {
                throw new TestException(
                        "Error occurred while copying data from file: " + srcFile + "\n " + e.getMessage());
            }
        }
        diskDirExists = true;
    }
}

From source file:eu.scape_project.tool.toolwrapper.toolwrapper_bash_debian_generator.DebianBashWrapperGenerator.java

private boolean copyPackage() {
    boolean res = true;

    // copy the Debian package
    for (File file : tempDebianBaseDir.listFiles(new DebianFileFilter())) {
        try {/*  ww w . j  a v a 2 s. com*/
            FileUtils.copyFileToDirectory(file,
                    new File(outputDirectory, Constants.DEBIANBASHGENERATOR_DEBS_OUTDIRNAME));
            break;
        } catch (IOException e) {
            log.error("Error while copying file \"" + file + "\" to directory \"" + outputDirectory + "\"");
            res = false;
        }
    }
    return res;
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

public static synchronized void HydraTask_copyDiskFiles_gemToSnappyCluster() {
    Set<File> myDirList = getDirList("dirName_");
    if (diskDirExists)
        return;/*from   w  ww . jav  a 2s.c o m*/
    else {
        String dirName = snappyTest.generateLogDirName();
        File destDir = new File(dirName);
        String[] splitedName = RemoteTestModule.getMyClientName().split("snappy");
        String newName = splitedName[1];
        File currentDir = new File(".");
        for (File srcFile1 : currentDir.listFiles()) {
            if (!doneCopying) {
                if (srcFile1.getAbsolutePath().contains(newName)
                        && srcFile1.getAbsolutePath().contains("_disk")) {
                    if (myDirList.contains(srcFile1)) {
                        Log.getLogWriter().info("List contains entry for the file... " + myDirList.toString());
                    } else {
                        SnappyBB.getBB().getSharedMap().put(
                                "dirName_" + RemoteTestModule.getMyPid() + "_" + snappyTest.getMyTid(),
                                srcFile1);
                        File dir = new File(srcFile1.getAbsolutePath());
                        Log.getLogWriter().info("Match found for file: " + srcFile1.getAbsolutePath());
                        for (File srcFile : dir.listFiles()) {
                            try {
                                if (srcFile.isDirectory()) {
                                    FileUtils.copyDirectoryToDirectory(srcFile, destDir);
                                    Log.getLogWriter().info("Done copying diskDirFile directory from ::"
                                            + srcFile + "to " + destDir);
                                } else {
                                    FileUtils.copyFileToDirectory(srcFile, destDir);
                                    Log.getLogWriter().info(
                                            "Done copying diskDirFile from ::" + srcFile + "to " + destDir);
                                }
                                doneCopying = true;
                            } catch (IOException e) {
                                throw new TestException("Error occurred while copying data from file: "
                                        + srcFile + "\n " + e.getMessage());
                            }
                        }
                    }
                }
            }
        }
        diskDirExists = true;
    }
}

From source file:com.photon.phresco.impl.HtmlApplicationProcessor.java

private boolean copyImagesToDestination(String sourceFile, String destinationFolder) throws PhrescoException {
    boolean filesCopied = true;
    try {//from w  ww .j a v a 2  s.  c o m
        File imageFile = new File(sourceFile);
        if (imageFile.exists() && new File(destinationFolder).exists()) {
            FileUtils.copyFileToDirectory(imageFile, new File(destinationFolder));
        } else {
            filesCopied = false;
        }
    } catch (Exception e) {
        filesCopied = false;
        throw new PhrescoException(e);
    }

    return filesCopied;
}

From source file:csg.files.CSGFiles.java

@Override
public void exportData() throws IOException {
    File selectedFile = new File((workspace.getCourseTemplateLocLabel().getText()));
    File destFile = new File(workspace.getExportLabel().getText());
    CourseData courseData = (CourseData) app.getCourseDataComponent();
    File bannerFile = new File(courseData.getBannerLink());
    File selectedImgFile = new File(selectedFile.getAbsolutePath() + "/images/");
    File publicHTMLFile = new File("../CourseGenTester/public_html/images/");

    File leftFooterFile = new File(courseData.getLeftFooterLink());
    File rightFooterFile = new File(courseData.getRightFooterLink());

    if (!bannerFile.getPath().contains(selectedFile.getAbsolutePath())) {
        FileUtils.copyFileToDirectory(bannerFile, selectedImgFile);
    }//ww  w.jav a 2  s.  com
    if (!leftFooterFile.getPath().contains(selectedFile.getAbsolutePath())) {
        FileUtils.copyFileToDirectory(leftFooterFile, selectedImgFile);
    }
    if (!rightFooterFile.getPath().contains(selectedFile.getAbsolutePath())) {
        FileUtils.copyFileToDirectory(rightFooterFile, selectedImgFile);
    }
    if (!bannerFile.getPath().contains("public_html")) {
        FileUtils.copyFileToDirectory(bannerFile, publicHTMLFile);
    }
    if (!leftFooterFile.getPath().contains("public_html")) {
        FileUtils.copyFileToDirectory(leftFooterFile, publicHTMLFile);
    }
    if (!rightFooterFile.getPath().contains("public_html")) {
        FileUtils.copyFileToDirectory(rightFooterFile, publicHTMLFile);
    }

    CourseData cd = (CourseData) app.getCourseDataComponent();

    if (workspace.getTitleTextField().getText().isEmpty()) {
        cd.setTitle("");
    } else {
        cd.setTitle(workspace.getTitleTextField().getText());
    }
    if (workspace.getInsNameTextField().getText().isEmpty()) {
        cd.setInsName("");
    } else {
        cd.setInsName(workspace.getInsNameTextField().getText());
    }
    if (workspace.getInsHomeTextField().getText().isEmpty()) {
        cd.setInsHome("");
    } else {
        cd.setInsHome(workspace.getInsHomeTextField().getText());
    }

    //        String newBanner = bannerFile.getName();
    //        courseData.setBannerLink("./images/" + newBanner);
    //
    //        String newLeft = leftFooterFile.getName();
    //        courseData.setLeftFooterLink("./images/" + newLeft);
    //
    //        String newRight = rightFooterFile.getName();
    //        courseData.setRightFooterLink("./images/" + newRight); sa

    String path = "../CourseGenTester/public_html/js/OfficeHoursGridData.json";
    saveData(app.getTADataComponent(), app.getRecitationDataComponent(), app.getScheduleDataComponent(),
            app.getProjectDataComponent(), app.getCourseDataComponent(), path);

    String pathTA = "../CourseGenTester/public_html/js/TAsData.json";
    saveTAData(app.getTADataComponent(), pathTA);

    String pathRec = "../CourseGenTester/public_html/js/RecitationsData.json";
    saveRecitationData(app.getRecitationDataComponent(), pathRec);

    String pathSch = "../CourseGenTester/public_html/js/ScheduleData.json";
    saveScheduleData(app.getScheduleDataComponent(), pathSch);

    String pathCourseData = "../CourseGenTester/public_html/js/CourseData.json";
    saveCourseData(app.getCourseDataComponent(), pathCourseData);

    String pathTeamsStudents = "../CourseGenTester/public_html/js/TeamsAndStudents.json";
    saveTeamsAndStudentsData(app.getProjectDataComponent(), pathTeamsStudents);

    String pathCourse = "../CourseGenTester/public_html/js/ProjectsData.json";
    saveProjectsData(app.getCourseDataComponent(), app.getProjectDataComponent(), pathCourse);

    String path2 = selectedFile.getAbsolutePath() + "/js/OfficeHoursGridData.json";
    saveData(app.getTADataComponent(), app.getRecitationDataComponent(), app.getScheduleDataComponent(),
            app.getProjectDataComponent(), app.getCourseDataComponent(), path2);

    String path2TA = selectedFile.getAbsolutePath() + "/js/TAsData.json";
    saveTAData(app.getTADataComponent(), path2TA);

    String path2Rec = selectedFile.getAbsolutePath() + "/js/RecitationsData.json";
    saveRecitationData(app.getRecitationDataComponent(), path2Rec);

    String path2Sch = selectedFile.getAbsolutePath() + "/js/ScheduleData.json";
    saveScheduleData(app.getScheduleDataComponent(), path2Sch);

    String path2CourseData = selectedFile.getAbsolutePath() + "/js/CourseData.json";
    saveCourseData(app.getCourseDataComponent(), path2CourseData);

    String path2TeamsStudents = selectedFile.getAbsolutePath() + "/js/TeamsAndStudents.json";
    saveTeamsAndStudentsData(app.getProjectDataComponent(), path2TeamsStudents);

    String path2Course = selectedFile.getAbsolutePath() + "/js/ProjectsData.json";
    saveProjectsData(app.getCourseDataComponent(), app.getProjectDataComponent(), path2Course);

    FileUtils.copyDirectory(selectedFile, destFile);
}

From source file:com.freedomotic.jfrontend.MainWindow.java

/**
 *
 * @param backgroundImage/*from w ww . j  av a2 s.c  o  m*/
 * @return
 */
private File moveBackgroundFile(File backgroundImage) {
    File resourcesFolder = new File(Info.PATHS.PATH_DATA_FOLDER + File.separator + "resources" + File.separator
            + "system" + File.separator + "map");

    if (backgroundImage.exists() && resourcesFolder.isDirectory()
            && !(new File(resourcesFolder, backgroundImage.getName()).exists())) {
        try {
            FileUtils.copyFileToDirectory(backgroundImage, resourcesFolder);
            backgroundImage = new File(resourcesFolder, backgroundImage.getName());
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    return backgroundImage;
}

From source file:com.ah.ui.actions.monitor.MapsAction.java

public String execute() throws Exception {
    Date start = new Date();
    String forward = globalForward();
    if (forward != null) {
        return forward;
    }//from   w  w w . java2  s  . c om

    try {
        planToolConfig = PlanToolAction.getPlanToolConfig(domainId);
        MapContainerNode mapContainerNode = id == null ? null
                : (MapContainerNode) findBoById(MapNode.class, id, this);
        if ("mapClient".equals(operation)) {
            log.info("execute", "locate client: " + clientId + ", circle: " + ch1);
            if (clientId != null) {
                // AhClientSession client = QueryUtil.findBoById(
                // AhClientSession.class, clientId);
                AhClientSession client = DBOperationUtil.findBoById(AhClientSession.class, clientId);
                if (client != null) {
                    bssid = client.getClientMac();
                    bssidType = BSSID_TYPE_CLIENT;
                    if (ch1 == 1) {
                        bssid = '|' + bssid;
                    }
                }
            }
            return mapPage(start);
        } else if ("mapRogue".equals(operation)) {
            log.info("execute", "locate rogue: " + clientId);
            if (clientId != null) {
                Idp rogue = QueryUtil.findBoById(Idp.class, clientId);
                if (rogue != null) {
                    bssid = rogue.getIfMacAddress();
                    bssidType = BSSID_TYPE_ROGUE;
                }
            }
            return mapPage(start);
        } else if ("mapDetails".equals(operation)) {
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            mapAlarmsCache.setMapId(id, pageId);
            mapAlarmsCache.setTreeNodeExpanded(id, true);
            prepareMapNode(mapContainerNode);
            if (null != HmBeTopoUtil.getPollingController()) {
                // put this map container into polling list.
                HmBeTopoUtil.getPollingController().addContainer(this.request.getSession(), id);
            }
            // save the selected map id into session
            setSelectedMapId(id);
            return "json";
        } else if ("nodes".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", apLabels: " + apLabels);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonObject = prepareNodes(mapAlarmsCache.getMapNodes(id, pageId), pageId, scale);
            Map<Short, Short> ch1IndexMap = createChIndexMap(null, null);
            Map<Short, Short> ch2IndexMap = createChIndexMap(null, null);
            List<MapContainerNode> floors = BoMgmt.getLocationTracking().assignChannels(mapContainerNode,
                    planToolConfig, ch1IndexMap, ch2IndexMap);
            if (mapContainerNode.getMapType() == MapContainerNode.MAP_TYPE_FLOOR) {
                // Resetting floor cache
                FloorCache cache = new FloorCache(id);
                saveChannelAssignments(mapContainerNode, floors, cache, ch1IndexMap, ch2IndexMap, false);
                log.info("Resetting floor cache.");
                setFloorCache(cache);
            } else {
                removeFloorCache();
            }
            jsonObject.put("pageId", pageId);
            jsonObject.put("planned",
                    preparePlannedAPs(mapContainerNode, false, scale, null, ch1IndexMap, ch2IndexMap));
            jsonObject.put("perim", preparePerimeter(mapContainerNode.getPerimeter(), scale));
            jsonObject.put("walls", prepareWalls(mapContainerNode.getWalls(), scale));
            log.debug("execute", "Prepared nodes: " + jsonObject.toString());
            log.info_ln("maps.action nodes: " + (new Date().getTime() - start.getTime()) + " ms.");
            return "json";
        } else if ("links".equals(operation)) {
            log.info("execute", "Scale: " + scale);
            jsonObject = prepareLinks(mapContainerNode.getChildLinks().values(), pageId, getShowRssi());
            log.debug("execute", "Prepared links: " + jsonObject.toString());
            log.info_ln("maps.action links: " + (new Date().getTime() - start.getTime()) + " ms.");
            return "json";
        } else if ("alarms".equals(operation)) {
            log.info("execute", "Polling for new alarms, scale: " + scale + ", rogueChecked?" + rogueChecked
                    + ", clientChecked?" + clientChecked + ", summaryChecked?" + summaryChecked);
            prepareAlarms(id);
            log.info("execute", "Returning alarms:" + jsonObject.toString());
            return "json";
        } else if ("saveNode".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", nodeId: " + bssid + ", x: " + pwr1 + ", y: " + ch1);
            MgrUtil.removeSessionAttribute(SessionKeys.MR_HEAT_MAP);
            saveNode(Long.parseLong(bssid.substring(1)), pwr1, ch1);
            return "json";
        } else if ("saveNodes".equals(operation)) {
            log.info("execute", "Scale: " + scale);
            MgrUtil.removeSessionAttribute(SessionKeys.MR_HEAT_MAP);
            if (selectedIds != null) {
                for (int i = 0; i < selectedIds.size(); i++) {
                    saveNode(selectedIds.get(i), xs.get(i), ys.get(i));
                }
            }
            return null;
        } else if ("validatePerimeter".equals(operation)) {
            log.info("execute", "Scale: " + scale);
            Point2D[] walls = null;
            if (xs != null) {
                walls = new Point2D[xs.size()];
                for (int i = 0; i < xs.size(); i++) {
                    walls[i] = new Point2D.Double(xs.get(i), ys.get(i));
                    log.info("execute", "Perimeter node: " + walls[i].toString());
                }
            }
            jsonArray = new JSONArray(validatePerimeter(walls, mapContainerNode.getPerimeter(), scale));
            return "json";
        } else if ("clients".equals(operation)) {
            log.info("execute", "Scale: " + scale);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonObject = prepareClients(mapContainerNode, mapAlarmsCache.getMapNodes(id, pageId), pageId,
                    scale);
            log.debug("execute", "Prepared clients: " + jsonObject.toString());
            return "json";
        } else if ("rogues".equals(operation)) {
            log.info("execute", "Scale: " + scale);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonObject = prepareRogues(mapContainerNode, mapAlarmsCache.getMapNodes(id, pageId), pageId, scale);
            log.debug("execute", "Prepared rogues: " + jsonObject.toString());
            return "json";
        } else if ("acspNbrRssi".equals(operation)) {
            log.info("execute",
                    "acspNbrRssi Scale: " + scale + ", frequency: " + frequency + ", leafNodeId: " + acspId);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonObject = BoMgmt.getLocationTracking().acspNbrRssi(mapContainerNode,
                    mapAlarmsCache.getMapNodes(id, pageId), pageId, scale, acspId, (frequency & 1) > 0);
            return "json";
        } else if ("clientRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonArray = new JSONArray(BoMgmt.getLocationTracking().clientRssi(mapContainerNode,
                    mapAlarmsCache.getMapNodes(id, pageId), pageId, scale, bssid));
            log.debug("execute", "Prepared rssi: " + jsonArray.toString());
            return "json";
        } else if ("clientRssiArea".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid + ", canvas: (" + canvasWidth + ", "
                    + canvasHeight + ")");
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            BoMgmt.getLocationTracking().clientRssi(mapContainerNode, mapAlarmsCache.getMapNodes(id, pageId),
                    pageId, scale, bssid);
            streamImage(BoMgmt.getLocationTracking().drawRssiArea(mapContainerNode, canvasWidth, canvasHeight));
            return null;
        } else if ("rogueRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            jsonArray = new JSONArray(BoMgmt.getLocationTracking().rogueRssi(mapContainerNode,
                    mapAlarmsCache.getMapNodes(id, pageId), pageId, scale, bssid));
            log.debug("execute", "Prepared rssi: " + jsonArray.toString());
            return "json";
        } else if ("rogueRssiArea".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid + ", canvas: (" + canvasWidth + ", "
                    + canvasHeight + ")");
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            BoMgmt.getLocationTracking().rogueRssi(mapContainerNode, mapAlarmsCache.getMapNodes(id, pageId),
                    pageId, scale, bssid);
            streamImage(BoMgmt.getLocationTracking().drawRssiArea(mapContainerNode, canvasWidth, canvasHeight));
            return null;
        } else if ("calibrateClientRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            log.info("execute", "x: " + xs + ", y: " + ys);
            int added = 0;
            if (xs != null && ys != null) {
                double x = reverseScale(xs.get(0));
                double y = reverseScale(ys.get(0));
                log.info("execute", "x: " + x + ", y: " + y);
                added = BoMgmt.getLocationTracking().calibrateClient(mapContainerNode,
                        mapAlarmsCache.getMapNodes(id, pageId), pageId, scale, bssid, x, y);
            }
            jsonObject = new JSONObject();
            jsonObject.put("added", added);
            jsonObject.put("mac", bssid);
            log.debug("execute", "calibrate rssi: " + jsonObject.toString());
            return "json";
        } else if ("uncalibrateClientRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MgrUtil.removeSessionAttribute(SessionKeys.MR_HEAT_MAP);
            int removed = QueryUtil.bulkRemoveBos(Trex.class, new FilterParams("tid", bssid),
                    mapContainerNode.getOwner().getId());
            log.info("execute", removed + " measurements removed.");
            jsonObject = new JSONObject();
            jsonObject.put("removed", removed);
            jsonObject.put("mac", bssid);
            log.debug("execute", "uncalibrate rssi: " + jsonObject.toString());
            return "json";
        } else if ("calibrateRogueRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            log.info("execute", "x: " + xs + ", y: " + ys);
            int added = 0;
            if (xs != null && ys != null) {
                double x = reverseScale(xs.get(0));
                double y = reverseScale(ys.get(0));
                log.info("execute", "x: " + x + ", y: " + y);
                added = BoMgmt.getLocationTracking().calibrateRogue(mapContainerNode,
                        mapAlarmsCache.getMapNodes(id, pageId), pageId, scale, bssid, x, y);
            }
            jsonObject = new JSONObject();
            jsonObject.put("added", added);
            log.debug("execute", "calibrate rssi: " + jsonObject.toString());
            return "json";
        } else if ("uncalibrateRogueRssi".equals(operation)) {
            log.info("execute", "Scale: " + scale + ", bssid: " + bssid);
            MgrUtil.removeSessionAttribute(SessionKeys.MR_HEAT_MAP);
            int removed = QueryUtil.bulkRemoveBos(Trex.class, new FilterParams("tid", bssid),
                    mapContainerNode.getOwner().getId());
            log.info("execute", removed + " measurements removed.");
            jsonObject = new JSONObject();
            jsonObject.put("removed", removed);
            log.debug("execute", "uncalibrate rssi: " + jsonObject.toString());
            return "json";
        } else if ("locateClient".equals(operation)) {
            log.info("execute", "Locating client: " + clientId + ", circle: " + ch1);
            jsonObject = BoMgmt.getLocationTracking().validateClientLocation(getDomain(), clientId, ch1 == 1);
            log.debug("execute", "locate client result: " + jsonObject.toString());
            return "json";
        } else if ("locateRogue".equals(operation)) {
            log.info("execute", "Locating rogue: " + clientId);
            jsonObject = BoMgmt.getLocationTracking().validateRogueLocation(getDomain(), clientId);
            log.debug("execute", "locate rogue result: " + jsonObject.toString());
            return "json";
        } else if ("heatMapHr".equals(operation)) {
            log.info("execute", "HR version of latchId: " + latchId + ", frequency: " + frequency);
            if (BoMgmt.getLocationTracking().estimateRssiHr(mapContainerNode, latchId)) {
                streamMapImage(mapContainerNode, MapSettings.HEATMAP_RESOLUTION_HIGH, frequency, layers,
                        (short) -1, 1, null, (short) 0, 0, 0);
            }
            return null;
        } else if ("heatMap".equals(operation)) {
            log.info("execute", "scale: " + scale);
            log.info("execute", "rssiThreshold: -" + rssiThreshold);
            if (scale > 0) {
                log.info("execute",
                        "canvas: (" + canvasWidth + ", " + canvasHeight + "), layers: " + layers + ", mac: "
                                + bssid + ", acspNbr: " + acspId + ", nextId: " + nextId + ", position (" + xs
                                + ", " + ys + ")" + ", actualWidth: " + mapContainerNode.getActualWidth());
                MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
                Set<MapNode> nodes = mapAlarmsCache.getMapNodes(id, pageId);
                log.info("execute", "Preparing heat map, latch ID: " + latchId);
                if (nodes.size() > 0 && mapContainerNode != null && canvasWidth > 0 && canvasHeight > 0
                        && mapContainerNode.getActualWidth() > 0) {
                    log.info("execute", "# nodes: " + nodes.size());
                    double x = 0, y = 0;
                    if (xs != null && ys != null) {
                        x = reverseScale(xs.get(0));
                        y = reverseScale(ys.get(0));
                    }
                    log.info("execute", "x: " + x + ", y: " + y);
                    int heatmapResolution = BoMgmt.getLocationTracking().computeRssi(mapContainerNode, nodes,
                            canvasWidth, canvasHeight, bssid, acspId, nextId, x, y, (frequency & 1) > 0,
                            (frequency & 2) > 0, getShadesPerColor(), latchId);
                    mapAlarmsCache.createHeatMapLatch(latchId, heatmapResolution);
                    log.info("execute", "Create channels latch ID: " + latchId);
                    if (heatmapResolution < 0) {
                        // No measurements or calibration failed (clbrb_w)
                        streamImage(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));
                    } else {
                        streamMapImage(mapContainerNode, heatmapResolution, frequency, layers, (short) -1, 1,
                                null, (short) 0, 0, 0);
                    }
                }
            }
            return null;
        } else if ("channels".equals(operation)) {
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            Set<MapNode> nodes = mapAlarmsCache.getMapNodes(id, pageId);
            log.info("execute", "Get channels latch ID: " + latchId);
            int heatmapResolution = MapSettings.HEATMAP_RESOLUTION_HIGH;
            if (nodes.size() > 0 && mapContainerNode != null) {
                if (latchId == null) {
                    BoMgmt.getLocationTracking().fetchRadioAttributes(nodes);
                } else {
                    Integer hmr = mapAlarmsCache.getHeatMapLatch(latchId);
                    if (hmr == null) {
                        log.info("execute", "This is an obsoleted channel request, just return empty array.");
                        jsonArray = new JSONArray();
                        return "json";
                    } else {
                        heatmapResolution = hmr;
                    }
                }
            }
            log.info("execute", "Preparing node labels.");
            jsonArray = new JSONArray(prepareNodeChannels(nodes, pageId, (frequency & 1) > 0));
            if (jsonArray.length() > 0) {
                JSONObject fo = ((JSONObject) jsonArray.get(0));
                fo.put("latchId", latchId);
                fo.put("hmr", heatmapResolution);
            } else if (heatmapResolution < 0) {
                JSONObject fo = new JSONObject();
                fo.put("pageId", 0);
                fo.put("latchId", latchId);
                fo.put("hmr", heatmapResolution);
                Collection<JSONObject> jsonNodes = new Vector<JSONObject>();
                jsonNodes.add(fo);
                jsonArray = new JSONArray(jsonNodes);
            }
            log.debug("execute", "Prepared node labels: " + jsonArray.toString());
            return "json";
        } else if ("nextIds".equals(operation)) {
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            Set<MapNode> nodes = mapAlarmsCache.getMapNodes(id, pageId);
            log.info("execute", "Get next IDs for: " + latchId + ", frequency: " + frequency);
            jsonObject = new JSONObject();
            int heatmapResolution = BoMgmt.getLocationTracking().fetchActiveNbrs(mapContainerNode, nodes,
                    (frequency & 1) > 0, latchId, jsonObject);
            log.info("execute", "Preparing node labels.");
            jsonObject.put("latchId", latchId);
            jsonObject.put("hmr", heatmapResolution);
            jsonObject.put("pageId", pageId);
            jsonObject.put("channels", new JSONArray(prepareNodeChannels(nodes, pageId, (frequency & 1) > 0)));
            return "json";
        } else if ("rssiRange".equals(operation)) {
            log.info("execute", "rssiThreshold: -" + rssiThreshold);
            setSelectedRSSIThreshold(rssiThreshold);
            jsonArray = new JSONArray(BoMgmt.getLocationTracking().getRssiRange(getShadesPerColor()));
            log.debug("execute", "RSSI range: " + jsonArray.toString());
            return "json";
        } else if ("addSimAp".equals(operation)) {
            log.info("execute", "addSimAp, scale: " + scale + ", rssiThreshold: -" + rssiThreshold
                    + ", snrThreshold: " + snrThreshold + ", rateThreshold: " + rateThreshold);
            if (scale > 0 && mapContainerNode != null && canvasWidth > 0
                    && mapContainerNode.getActualWidth() > 0) {
                log.info("execute",
                        "canvas width: " + canvasWidth + ", frequency: " + frequency + ", layers: " + layers
                                + ", hwModel: " + hwModel + ", pwr (" + pwr1 + ", " + pwr2 + "), ch (" + ch1
                                + ", " + ch2 + "), all ch (" + ch1s + ", " + ch2s + "), all chi (" + ch1is
                                + ", " + ch2is + ", actualWidth: " + mapContainerNode.getActualWidth()
                                + ", locate X:" + latchId);
                // disable a radio which has one radio.
                if (hwModel == HiveAp.HIVEAP_MODEL_110 || hwModel == HiveAp.HIVEAP_MODEL_BR200_WP
                        || hwModel == HiveAp.HIVEAP_MODEL_BR200_LTE_VZ) {
                    planToolConfig.setWifi0Enabled((frequency & 1) > 0 ? false : true);
                    planToolConfig.setWifi1Enabled((frequency & 1) > 0 ? true : false);
                } else {
                    planToolConfig.setWifi0Enabled(true);
                    planToolConfig.setWifi1Enabled(hwModel != HiveAp.HIVEAP_MODEL_BR100);
                }
                planToolConfig.setDefaultApType(hwModel);
                planToolConfig.setWifi0Channel(ch1);
                planToolConfig.setWifi0Power(pwr1);
                planToolConfig.setWifi1Channel(ch2);
                planToolConfig.setWifi1Power(pwr2);
                PlanToolAction.savePlanToolConfig(planToolConfig, getDomain());
                addSimulatedAP(mapContainerNode, planToolConfig, latchId);
            }
            return "json";
        } else if ("autoSimAps".equals(operation)) {
            log.info("execute",
                    "Auto Sim APs, rssiThreshold: -" + rssiThreshold + ", frequency: " + frequency
                            + ", canvas (" + canvasWidth + ", " + canvasHeight + "), hwModel: " + hwModel
                            + ", pwr (" + pwr1 + ", " + pwr2 + "), ch (" + ch1 + ", " + ch2 + ")");
            if (mapContainerNode.getEnvironment() == EnumConstUtil.MAP_ENV_AUTO) {
                mapContainerNode.setEnvironment(EnumConstUtil.MAP_ENV_ENTERPRISE);
                QueryUtil.updateBo(mapContainerNode);
            }
            // disable a radio which has one radio.
            if (hwModel == HiveAp.HIVEAP_MODEL_110 || hwModel == HiveAp.HIVEAP_MODEL_BR200_WP
                    || hwModel == HiveAp.HIVEAP_MODEL_BR200_LTE_VZ) {
                planToolConfig.setWifi0Enabled((frequency & 1) > 0 ? false : true);
                planToolConfig.setWifi1Enabled((frequency & 1) > 0 ? true : false);
            } else {
                planToolConfig.setWifi0Enabled(true);
                planToolConfig.setWifi1Enabled(hwModel != HiveAp.HIVEAP_MODEL_BR100);
            }
            planToolConfig.setDefaultApType(hwModel);
            planToolConfig.setWifi0Channel(ch1);
            planToolConfig.setWifi0Power(pwr1);
            planToolConfig.setWifi1Channel(ch2);
            planToolConfig.setWifi1Power(pwr2);
            PlanToolAction.savePlanToolConfig(planToolConfig, getDomain());
            createAutoSimAps(mapContainerNode, planToolConfig,
                    BoMgmt.getLocationTracking().autoSimAps(mapContainerNode, planToolConfig, canvasWidth,
                            canvasHeight, (frequency & 1) > 0, getShadesPerColor(), 95.5));
            return "json";
        } else if ("updateSimApLaps".equals(operation)) {
            if (scale > 0 && mapContainerNode != null && canvasWidth > 0
                    && mapContainerNode.getActualWidth() > 0) {
                log.info("execute", "updateSimApLaps, canvas (" + canvasWidth + ", " + canvasHeight
                        + "), plannedId: " + bssid + ", hostName: " + hostName + ", pwr (" + pwr1 + ", " + pwr2
                        + "), ch (" + ch1 + ", " + ch2 + "), all ch (" + ch1s + ", " + ch2s + "), all chi ("
                        + ch1is + ", " + ch2is + "), x: " + pwr2 + ", y: " + ch2 + ", frequency: " + frequency
                        + ", channel width: " + channelWidth + ", fadeMargin: " + fadeMargin + ", layers: "
                        + layers + ", rssiThreshold: -" + rssiThreshold + ", snrThreshold: " + snrThreshold
                        + ", rateThreshold: " + rateThreshold + ", radio: " + radio);
                boolean useA = (frequency & 1) > 0;
                PlannedAP plannedAP = null;
                Map<Short, Short> ch1IndexMap = null;
                Map<Short, Short> ch2IndexMap = null;
                if (bssid.length() > 0) {
                    /*
                     * Update a single Planned AP, either its position
                     * (drag-n-drop), or the radio attributes (update AP
                     * details).
                     */
                    long plannedId = Long.parseLong(bssid.substring(1));
                    if (pwr1 > 0) {
                        /*
                         * Update planned AP
                         */
                        plannedAP = BoMgmt.getPlannedApMgmt().updatePlannedAP(mapContainerNode, plannedId,
                                hostName, hwModel, (short) ch1, (short) ch2, (short) pwr1, (short) pwr2, radio);
                    } else {
                        /*
                         * Move planned AP
                         */
                        plannedAP = BoMgmt.getPlannedApMgmt().movePlannedAP(mapContainerNode, plannedId,
                                reverseScale(pwr2), reverseScale(ch2));
                    }
                    FloorCache cache = clearNbrAps(mapContainerNode, plannedAP, plannedAP.getId(),
                            getFloorCache(id));
                    for (PlannedAP ap : mapContainerNode.getPlannedAPs()) {
                        if (ap.getId().equals(plannedAP.getId())) {
                            ap.apModel = plannedAP.apModel;
                            ap.hostName = plannedAP.hostName;
                            ap.countryCode = plannedAP.countryCode;
                            ap.wifi0Enabled = plannedAP.wifi0Enabled;
                            ap.wifi1Enabled = plannedAP.wifi1Enabled;
                            ap.wifi0Channel = plannedAP.wifi0Channel;
                            ap.wifi1Channel = plannedAP.wifi1Channel;
                            ap.wifi0Power = plannedAP.wifi0Power;
                            ap.wifi1Power = plannedAP.wifi1Power;
                            ap.x = plannedAP.x;
                            ap.y = plannedAP.y;
                        }
                    }
                    ch1IndexMap = createChIndexMap(ch1s, ch1is);
                    ch2IndexMap = createChIndexMap(ch2s, ch2is);
                    List<MapContainerNode> floors = BoMgmt.getLocationTracking()
                            .assignChannels(mapContainerNode, planToolConfig, ch1IndexMap, ch2IndexMap);
                    saveChannelAssignments(mapContainerNode, floors, cache, ch1IndexMap, ch2IndexMap, true);

                } else {
                    setSelectedLayers(layers);
                }
                Collection<JSONObject> jsonNodes = getPredictedLap(mapContainerNode, useA, plannedAP, (short) 0,
                        channelWidth, fadeMargin, false);
                if (plannedAP != null && jsonNodes.size() > 0) {
                    JSONObject jo = jsonNodes.iterator().next();
                    jo.put("planned",
                            preparePlannedAPs(mapContainerNode, true, scale, null, ch1IndexMap, ch2IndexMap));
                }
                jsonArray = new JSONArray(jsonNodes);
            }
            return "json";
        } else if ("predictedLap".equals(operation)) {
            if (scale > 0 && mapContainerNode != null && canvasWidth > 0
                    && mapContainerNode.getActualWidth() > 0) {
                log.info("execute",
                        "predictedLap: canvas (" + canvasWidth + ", " + canvasHeight + "), layers: " + layers
                                + ", power: " + pwr1 + ", chi: " + ch1 + ", channel width: " + channelWidth
                                + ", fadeMargin: " + fadeMargin + ", plannedId: " + bssid + ", rssiThreshold: -"
                                + rssiThreshold + ", snrThreshold: " + snrThreshold + ", rateThreshold: "
                                + rateThreshold);
                long plannedId = Long.parseLong(bssid.substring(1));
                PlannedAP plannedAP = BoMgmt.getPlannedApMgmt().findPlannedAP(plannedId);
                if (plannedAP != null) {
                    getPredictedLap(mapContainerNode, (frequency & 1) > 0, plannedAP, (short) ch1, channelWidth,
                            fadeMargin, true);
                }
            }
            return null;
        } else if ("cacheSpill".equals(operation)) {
            jsonObject = new JSONObject();
            FloorCache cache = getFloorCache(mapContainerNode.getId());
            if (cache == null || cache.mapChannels == null) {
                jsonObject.put("success", false);
                return "json";
            }
            jsonObject.put("w", cache.mapChannels.length * cache.imgScale);
            jsonObject.put("h", cache.mapChannels[0].length * cache.imgScale);
            cacheDoubleBuffer(mapContainerNode, cache, false);
            return "json";
        } else if ("updateSpillCache".equals(operation)) {
            log.info("execute", "updateSpillCache frequency: " + frequency + ", rssiThreshold: -"
                    + rssiThreshold + ", spillOnly: " + showSpill + ", channel width: " + channelWidth);
            jsonObject = new JSONObject();
            FloorCache cache = getFloorCache(mapContainerNode.getId());
            if (cache == null || cache.mapChannels == null) {
                jsonObject.put("success", false);
                return "json";
            }
            if (!showSpill) {
                cache.useA = (frequency & 1) > 0;
                cache.channelWidth = channelWidth;
                cache.shadesPerColor = getShadesPerColor();
            }
            int imageWidth = cache.spillRssi.length;
            int imageHeight = cache.spillRssi[0].length;
            cache.spillRssi = new float[imageWidth][imageHeight];
            cache.spillChannels = new short[imageWidth][imageHeight];
            if (!showSpill) {
                // Don't recalculate these
                cache.mapRssi = new float[imageWidth][imageHeight];
                cache.mapChannels = new short[imageWidth][imageHeight];
            }
            cacheDoubleBuffer(mapContainerNode, cache, showSpill);
            return "json";
        } else if ("planHeatMap".equals(operation)) {
            log.info("execute", "scale: " + scale);
            if (scale > 0 && mapContainerNode != null && canvasWidth > 0
                    && mapContainerNode.getActualWidth() > 0) {
                log.info("execute",
                        "canvas (" + canvasWidth + ", " + canvasHeight + "), rssiThreshold: -" + rssiThreshold);
                int resolution = BoMgmt.getLocationTracking().simApCoverage(mapContainerNode, planToolConfig,
                        canvasWidth, canvasHeight, (frequency & 1) > 0, getShadesPerColor());
                streamMapImage(mapContainerNode, resolution, frequency, 1, (short) -1, 1, null, (short) 0, 0,
                        0);
            }
            return null;
        } else if ("updateSnrThreshold".equals(operation)) {
            log.info("execute", "Updating SNR threshold to: " + snrThreshold);
            jsonObject = new JSONObject();
            setSelectedSNRThreshold(snrThreshold);
            jsonObject.put("success", true);
            return "json";
        } else if ("updateFadeMargin".equals(operation)) {
            log.info("execute", "Updating fade margin to: " + fadeMargin);
            jsonObject = new JSONObject();
            planToolConfig.setFadeMargin(fadeMargin);
            PlanToolAction.savePlanToolConfig(planToolConfig, getDomain());
            jsonObject.put("success", true);
            return "json";
        } else if ("updateChannelWidth".equals(operation)) {
            log.info("execute", "New channel width: " + channelWidth + ", model: " + hwModel);
            jsonObject = new JSONObject();
            planToolConfig.setChannelWidth(channelWidth);
            PlanToolAction.savePlanToolConfig(planToolConfig, getDomain());
            jsonObject.put("channels", new JSONArray(getChannelNaType(hwModel)));
            Map<Short, Short> ch1IndexMap = createChIndexMap(null, null);
            Map<Short, Short> ch2IndexMap = createChIndexMap(null, null);
            List<MapContainerNode> floors = BoMgmt.getLocationTracking().assignChannels(mapContainerNode,
                    planToolConfig, ch1IndexMap, ch2IndexMap);
            saveChannelAssignments(mapContainerNode, floors, getFloorCache(id), ch1IndexMap, ch2IndexMap, true);
            jsonObject.put("pageId", pageId);
            jsonObject.put("planned",
                    preparePlannedAPs(mapContainerNode, false, scale, null, ch1IndexMap, ch2IndexMap));
            return "json";
        } else if ("stopMapRefreshing".equals(operation)) {
            log.info("execute", "stop map refreshing for user:" + getUserContext().getUserName());
            if (null != HmBeTopoUtil.getPollingController()) {
                HmBeTopoUtil.getPollingController().removeContainer(request.getSession());
            }
            return null;
        } else if ("expandMapNode".equals(operation)) {
            log.info("execute", "operation:" + operation + ", map node:" + id + ", mapExpanded:" + mapExpanded);
            MapAlarmsCache<?> mapAlarmsCache = getMapAlarmsCache();
            mapAlarmsCache.setTreeNodeExpanded(id, mapExpanded);
            return "json";
        } else if ("createDownloadData".equals(operation)) {
            log.info("execute-createDownloadData",
                    "frequency: " + frequency + ", rssiThreshold: -" + rssiThreshold + ", rateThreshold: -"
                            + rateThreshold + ", channelWidth: -" + channelWidth + ", snrThreshold: "
                            + snrThreshold + ", layers: " + layers + ", gridChecked: " + gridChecked);
            jsonObject = new JSONObject();
            String pdfCreateFlagName = getDomain().getDomainName() + "_createingFlag";
            String pdfCreateSuccessFlagName = getDomain().getDomainName() + "_createSuccessFlag";
            String pdfCreateMapName = getDomain().getDomainName() + "_createingMapName";
            if (!"T".equals(MgrUtil.getSessionAttribute(pdfCreateFlagName))) {
                MgrUtil.setSessionAttribute(pdfCreateFlagName, "T");
                MgrUtil.setSessionAttribute(pdfCreateMapName, mapContainerNode.getMapName());
            } else {
                jsonObject.put("result", false);
                String msg = "The map of '" + MgrUtil.getSessionAttribute(pdfCreateMapName)
                        + "' is creating PDF report, please wait a moment.";
                jsonObject.put("message", msg);
                return "json";
            }

            MgrUtil.setSessionAttribute(pdfCreateSuccessFlagName, "F");

            TopoPdfReport report = new TopoPdfReport(this);

            String reportFile = "/tmp/report_" + getDomain().getDomainName() + ".pdf";
            boolean result = report.createPdf(mapContainerNode.getId(), reportFile, gridChecked, channelWidth,
                    acspId, planToolConfig);

            jsonObject.put("result", result);

            if (!result) {
                jsonObject.put("message", MgrUtil.getUserMessage("export.pdf.report.message"));
            } else {
                MgrUtil.setSessionAttribute(pdfCreateSuccessFlagName, "T");
            }
            MgrUtil.setSessionAttribute(pdfCreateFlagName, "F");
            return "json";
        } else if ("getPdfCreateFlag".equals(operation)) {
            String pdfCreateFlagName = getDomain().getDomainName() + "_createingFlag";
            String pdfCreateFlag = (String) MgrUtil.getSessionAttribute(pdfCreateFlagName);
            boolean flag = false;
            if ("T".equals(pdfCreateFlag)) {
                flag = true;
            }

            boolean success = false;
            String pdfCreateSuccessFlagName = getDomain().getDomainName() + "_createSuccessFlag";
            String pdfCreateSuccessFlag = (String) MgrUtil.getSessionAttribute(pdfCreateSuccessFlagName);
            if ("T".equals(pdfCreateSuccessFlag)) {
                success = true;
            }
            jsonObject = new JSONObject();
            jsonObject.put("pdfCreatingFlag", flag);
            jsonObject.put("pdfCreatSuccessFlag", success);
            return "json";
        } else if ("download".equals(operation)) {
            // check the file if under the allowed folder
            // StringUtils.isBlank(fileName) export pdf file
            boolean fileAllowed = true;
            if (!StringUtils.isBlank(fileName)) {
                fileAllowed = checkFileExistUnderDirectoryAllowed("/tmp/fdData/" + getDomain().getDomainName(),
                        fileName);
            }
            File file = new File(getInputPath());
            if (!fileAllowed || !file.exists()) {
                log.warn("No this file: " + getInputPath());
                addActionError(MgrUtil.getUserMessage("action.error.cannot.find.file"));
                return null;
            }
            return "download";
        } else if ("createPlanningData".equals(operation)) {
            jsonObject = new JSONObject();
            if (null != mapContainerNode.getId()) {
                final String time_suffix = "" + new Date().getTime();
                String fileName = mapContainerNode.getMapName() + "_" + time_suffix + ".xml";
                String destFilePath = getFolderDataFileRealPath(fileName);
                TopoXMLConvertor convertor = new TopoXMLConvertor(true);
                MapContainerNode container = (MapContainerNode) QueryUtil.findBoById(MapNode.class,
                        mapContainerNode.getId(), convertor.getLazyBoLoader());
                BooleanMsgPair result = convertor.convert2XML(container, destFilePath);

                String name = makeXMLBgImages2Tar(mapContainerNode.getMapName(), time_suffix, destFilePath,
                        convertor.getBackgroundImageNames());
                if (null != name) {
                    fileName = name;
                }

                jsonObject.put("succ", result.getValue());
                jsonObject.put("msg", result.getDesc());
                jsonObject.put("fileName", fileName);
            }
            return "json";
        } else if ("uploadPlanningData".equals(operation)) {
            // TODO limit the size of file
            jsonObject = new JSONObject();
            if (StringUtils.isBlank(uploadXmlFileName) || null == uploadXml) {
                jsonObject.put("msg", MgrUtil.getUserMessage("error.topo.import.xml.invalid.param"));
            } else {
                if (uploadXmlFileName.endsWith(".xml")) {
                    // normal
                    parseDataFromXML(uploadXml);
                } else {
                    // tarball
                    final String time_suffix = "" + new Date().getTime();
                    final String destPath = getTarFolderPath() + "/" + time_suffix;
                    if (new TarArchive().extract(uploadXml.getAbsolutePath(), destPath)) {
                        File folder = new File(destPath);
                        File[] files = folder.listFiles();

                        File[] imageFiles = null;
                        boolean parseSucc = false;

                        for (File file : files) {
                            if (file.isFile()) {
                                parseSucc = parseDataFromXML(file);
                            } else {
                                // copy map background images
                                imageFiles = file.listFiles();
                            }
                        }
                        if (parseSucc && null != imageFiles) {
                            String imagepath = BeTopoModuleUtil
                                    .getRealTopoBgImagePath(getDomain().getDomainName());
                            if (overrideBg) {
                                for (File imageFile : imageFiles) {
                                    FileUtils.copyFileToDirectory(imageFile, new File(imagepath));
                                }
                            } else {
                                for (File imageFile : imageFiles) {
                                    if (!new File(imagepath, imageFile.getName()).exists()) {
                                        FileUtils.copyFileToDirectory(imageFile, new File(imagepath));
                                    }
                                }

                            }
                        }
                    } else {
                        jsonObject.put("msg", "Unable to extra the file: " + uploadXmlFileName);
                    }
                }

            }
            return "json";
        } else if ("viewFloor".equals(operation)) {
            log.info_ln("View floor: " + id);
            setSelectedMapId(id);
            return mapPage(start);
        } else {
            return mapPage(start);
        }
    } catch (Exception e) {
        log.error("execute", "execute error. operation:" + operation, e);
        addActionError(MgrUtil.getUserMessage(e));
        return mapPage(start);
    }
}

From source file:hydrograph.ui.parametergrid.dialog.MultiParameterFileDialog.java

private boolean importParamterFileToProject(String[] listOfFilesToBeImported, String source, String destination,
        ParamterFileTypes paramterFileTypes) {

    for (String fileName : listOfFilesToBeImported) {
        String absoluteFileName = source + fileName;
        IPath destinationIPath = new Path(destination);
        destinationIPath = destinationIPath.append(fileName);
        File destinationFile = destinationIPath.toFile();
        try {/*from  w w  w  .ja v  a2 s  .com*/
            if (!ifDuplicate(listOfFilesToBeImported, paramterFileTypes)) {
                if (StringUtils.equalsIgnoreCase(absoluteFileName, destinationFile.toString())) {
                    return true;
                } else if (destinationFile.exists()) {
                    int returnCode = doUserConfirmsToOverRide();
                    if (returnCode == SWT.YES) {
                        FileUtils.copyFileToDirectory(new File(absoluteFileName), new File(destination));
                    } else if (returnCode == SWT.NO) {
                        return true;
                    } else {
                        return false;
                    }
                } else {
                    FileUtils.copyFileToDirectory(new File(absoluteFileName), new File(destination));
                }
            }
        } catch (IOException e1) {
            if (StringUtils.endsWithIgnoreCase(e1.getMessage(),
                    ErrorMessages.IO_EXCEPTION_MESSAGE_FOR_SAME_FILE)) {
                return true;
            }
            MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK);
            messageBox.setText(MessageType.ERROR.messageType());
            messageBox.setMessage(ErrorMessages.UNABLE_TO_POPULATE_PARAM_FILE + " " + e1.getMessage());
            messageBox.open();
            logger.error("Unable to copy prameter file in current project work space");
            return false;
        }
    }
    return true;
}