package com.otognan.driverpete.logic.routes;


import java.io.IOException;
import java.security.Principal;
import java.text.ParseException;
import java.util.List;

import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.otognan.driverpete.security.User;


@RestController
public class RoutesController {
    
    @Autowired
    private RoutesService routesService;
    
    @RequestMapping(value = "/api/trajectory/routes", method = RequestMethod.GET)
    public List<byte[]> routes(Principal principal, @RequestParam("isAtoB") boolean isAtoB) throws IOException, ParseException {
        User user = (User)((Authentication)principal).getPrincipal();
        List<byte[]> binaryRoutes = this.routesService.getBinaryRoutes(user, isAtoB);
        for (int i = 0; i < binaryRoutes.size(); i++) {
            binaryRoutes.set(i, Base64.encodeBase64(binaryRoutes.get(i)));
        }
        return binaryRoutes;
    }
}
@@ -125,32 +125,60 @@
 ParseException;%0A
+import java.util.ArrayList;%0A
 import java.util
@@ -861,22 +861,22 @@
 ic List%3C
-byte%5B%5D
+String
 %3E routes
@@ -1142,55 +1142,119 @@
     
-for (int i = 0; i %3C binaryRoutes.size(); i++) %7B
+List%3CString%3E stringRoutes = new ArrayList%3CString%3E();%0A        for (byte%5B%5D binRoute: binaryRoutes) %7B%0A            
 %0A   
@@ -1266,28 +1266,36 @@
     
-binary
+string
 Routes.
-set(i, 
+add(new String(
 Base
@@ -1317,23 +1317,13 @@
 (bin
-ary
 Route
-s.get(i
 )));
@@ -1348,22 +1348,22 @@
  return 
-binary
+string
 Routes;%0A

send as string