Search in sources :

Example 11 with PremiumUserDevice

use of net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice in project OsmAnd-tools by osmandapp.

the class UserdataController method listFiles.

@GetMapping(value = "/list-files")
@ResponseBody
public ResponseEntity<String> listFiles(@RequestParam(name = "deviceid", required = true) int deviceId, @RequestParam(name = "accessToken", required = true) String accessToken, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "type", required = false) String type, @RequestParam(name = "allVersions", required = false, defaultValue = "false") boolean allVersions) throws IOException, SQLException {
    PremiumUserDevice dev = checkToken(deviceId, accessToken);
    if (dev == null) {
        return tokenNotValid();
    }
    UserFilesResults res = generateFiles(dev.userid, name, type, allVersions, false);
    return ResponseEntity.ok(gson.toJson(res));
}
Also used : PremiumUserDevice(net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with PremiumUserDevice

use of net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice in project OsmAnd-tools by osmandapp.

the class UserdataController method remapFilenames.

@PostMapping(value = "/remap-filenames")
@ResponseBody
public ResponseEntity<String> remapFilenames(@RequestParam(name = "deviceid", required = true) int deviceId, @RequestParam(name = "accessToken", required = true) String accessToken) throws IOException, SQLException {
    PremiumUserDevice dev = checkToken(deviceId, accessToken);
    if (dev == null) {
        return tokenNotValid();
    }
    // remap needs to happen to all users & temporarily service should find files by both names (download)
    Iterable<UserFile> lst = filesRepository.findAllByUserid(dev.userid);
    for (UserFile fl : lst) {
        if (fl != null && fl.filesize > 0) {
            storageService.remapFileNames(fl.storage, userFolder(fl), oldStorageFileName(fl), storageFileName(fl));
        }
    }
    return ok();
}
Also used : UserFile(net.osmand.server.api.repo.PremiumUserFilesRepository.UserFile) PremiumUserDevice(net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with PremiumUserDevice

use of net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice in project OsmAnd-tools by osmandapp.

the class UserdataController method delete.

@PostMapping(value = "/delete-file")
@ResponseBody
public ResponseEntity<String> delete(@RequestParam(name = "name", required = true) String name, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "deviceid", required = true) int deviceId, @RequestParam(name = "accessToken", required = true) String accessToken, @RequestParam(name = "clienttime", required = false) Long clienttime) throws IOException {
    PremiumUserDevice dev = checkToken(deviceId, accessToken);
    if (dev == null) {
        return tokenNotValid();
    }
    UserFile usf = new PremiumUserFilesRepository.UserFile();
    usf.name = name;
    usf.type = type;
    usf.updatetime = new Date();
    usf.userid = dev.userid;
    usf.deviceid = deviceId;
    usf.data = null;
    usf.filesize = -1l;
    usf.zipfilesize = -1l;
    if (clienttime != null) {
        usf.clienttime = new Date(clienttime.longValue());
    }
    filesRepository.saveAndFlush(usf);
    return ok();
}
Also used : UserFile(net.osmand.server.api.repo.PremiumUserFilesRepository.UserFile) PremiumUserDevice(net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PremiumUserDevice (net.osmand.server.api.repo.PremiumUserDevicesRepository.PremiumUserDevice)13 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 UserFile (net.osmand.server.api.repo.PremiumUserFilesRepository.UserFile)8 GetMapping (org.springframework.web.bind.annotation.GetMapping)7 PostMapping (org.springframework.web.bind.annotation.PostMapping)5 Date (java.util.Date)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 GPXFile (net.osmand.GPXUtilities.GPXFile)3 GPXTrackAnalysis (net.osmand.GPXUtilities.GPXTrackAnalysis)3 PremiumUser (net.osmand.server.api.repo.PremiumUsersRepository.PremiumUser)3 ResponseEntity (org.springframework.http.ResponseEntity)2 IOException (java.io.IOException)1 UserFileNoData (net.osmand.server.api.repo.PremiumUserFilesRepository.UserFileNoData)1 UserFilesResults (net.osmand.server.controllers.pub.UserdataController.UserFilesResults)1