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));
}
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();
}
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();
}
Aggregations