package seedu.tasklist.logic.commands;

import java.io.IOException; 

import seedu.tasklist.logic.commands.exceptions.CommandException;

/**
 * Load user data file for task list.
 */
public class LoadCommand extends Command {
    
    public static final String COMMAND_WORD = "load";
    
    public static final String MESSAGE_USAGE = COMMAND_WORD + ": loads data from specified location.\n"
            + "Parameters: FILE_PATH/FILE_NAME.xml\n"
            + "Example: " + COMMAND_WORD + " data/mytasklist.xml";

    public static final String MESSAGE_SUCCESS = "Data successfully loaded from: %1$s";
    public static final String MESSAGE_FAILURE = "The file cannot be loaded: %1$s";
 
    private String filePath;
    
    public LoadCommand(String filePath){
        assert filePath != null;
        this.filePath = filePath.trim();
    }
    
    @Override
    public CommandResult execute() throws CommandException {
       assert model != null;
       try{
           model.loadTaskList(filePath);
           return new CommandResult(String.format(MESSAGE_SUCCESS, filePath));
       }catch (IOException e){
           return new CommandResult(String.format(MESSAGE_FAILURE, filePath));
       }
    }


}

@@ -60,17 +60,87 @@
 ception;
- 
+%0Aimport java.nio.file.InvalidPathException;%0Aimport java.nio.file.Paths;
 %0A%0Aimport
@@ -289,20 +289,16 @@
 mmand %7B%0A
-    
 %0A    pub
@@ -344,20 +344,16 @@
 %22load%22;%0A
-    
 %0A    pub
@@ -659,16 +659,114 @@
  %251$s%22;%0A
+    public static final String MESSAGE_INVALID_PATH = %22The file path specified is invalid: %251$s%22;%0A
     publ
@@ -841,17 +841,16 @@
  %251$s%22;%0A
- 
 %0A    pri
@@ -871,24 +871,66 @@
 lePath;%0A    
+private static final String XML = %22.xml%22;%0A
 %0A    public 
@@ -961,42 +961,10 @@
 ath)
+ 
 %7B
-%0A        assert filePath != null;
 %0A   
@@ -1007,20 +1007,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Ov
@@ -1101,23 +1101,166 @@
 ert 
-model != null;%0A
+filePath != null;%0A       assert model != null;%0A%0A        if (!isValidPath(filePath)) %7B%0A            return new CommandResult(MESSAGE_INVALID_PATH);%0A        %7D%0A%0A 
     
@@ -1265,18 +1265,20 @@
      try
+ 
 %7B%0A
+ 
         
@@ -1310,16 +1310,17 @@
 ePath);%0A
+ 
         
@@ -1390,24 +1390,25 @@
 Path));%0A
+ 
        %7D
 catch (I
@@ -1399,16 +1399,17 @@
        %7D
+ 
 catch (I
@@ -1421,18 +1421,20 @@
 ption e)
+ 
 %7B%0A
+ 
         
@@ -1500,24 +1500,25 @@
 filePath));%0A
+ 
        %7D%0A   
@@ -1521,11 +1521,464 @@
 %0A    %7D%0A%0A
+    /**%0A     * Returns true if the given path is a valid path%0A     */%0A    private boolean isValidPath(String path) %7B%0A        try %7B%0A            Paths.get(path);%0A            return isXML(path);%0A        %7D catch (InvalidPathException e) %7B%0A            return false;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns true if the given path ends with the .xml extension.%0A     */%0A    private static boolean isXML(String path) %7B%0A        return path.endsWith(XML);%0A    %7D%0A%0A%0A
 %0A%7D%0A

Update LoadCommand.java