//@@author A0163720M
package seedu.address.logic.commands;

import java.io.File;
import java.io.IOException;

import seedu.address.commons.core.Config;
import seedu.address.commons.exceptions.DataConversionException;
import seedu.address.commons.util.ConfigUtil;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.storage.StorageManager;

public class SaveFileCommand extends Command {
    private String saveFilePath;
    public static final String MESSAGE_SAVE_FILE_ERROR = "Cannot write to a file that does not exist.";
    public static final String MESSAGE_CONFIG_ERROR = "Error handling the config file.";
    public static final String MESSAGE_SUCCESS = "Save file updated!";
    public static final String COMMAND_WORD = "savefile";
    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Updates the save file location.\n"
            + "Parameters: PATH (must be a valid path string pointing to existing .xml file)\n" + "Example: "
            + COMMAND_WORD + " data/newtodolist.xml";

    public SaveFileCommand(String saveFilePath) {
        this.saveFilePath = saveFilePath;
    }

    @Override
    public CommandResult execute() throws CommandException {
        File f = new File(saveFilePath);

        if (!f.exists() || f.isDirectory()) {
            throw new CommandException(MESSAGE_SAVE_FILE_ERROR);
        }

        try {
            // There should only be one instance of config each session - grab a
            // handle on that specific one
            Config config = ConfigUtil.readConfig(Config.DEFAULT_CONFIG_FILE).get();
            String todoListFilePath = config.getTodoListFilePath();
            String userPrefsFilePath = config.getUserPrefsFilePath();
            StorageManager storageManager = new StorageManager(todoListFilePath,  userPrefsFilePath);
            storageManager.updateSaveFilePath(saveFilePath);
            return new CommandResult(MESSAGE_SUCCESS);
        } catch (DataConversionException e) {
            // Catch for data conversion from Optional<Config> to Config
            throw new CommandException(MESSAGE_CONFIG_ERROR);
        } catch (IOException e) {
            throw new CommandException(MESSAGE_SAVE_FILE_ERROR);
        }
    }
}

@@ -365,16 +365,60 @@
 Manager;
+%0Aimport seedu.address.commons.core.Messages;
 %0A%0Apublic
@@ -495,112 +495,8 @@
 th;%0A
-    public static final String MESSAGE_SAVE_FILE_ERROR = %22Cannot write to a file that does not exist.%22;%0A
     
@@ -1276,38 +1276,46 @@
 eption(M
-ESSAGE_SAVE_FILE_ERROR
+essages.MESSAGE_FILE_NOT_FOUND
 );%0A     
@@ -2158,30 +2158,38 @@
 on(M
-ESSAGE_SAVE_FILE_ERROR
+essages.MESSAGE_FILE_NOT_FOUND
 );%0A 

Removing unnecessary string constant