dizda13 2017-04-16 18:14:01 +02:00
commit b8c3c16124
7 changed files with 26 additions and 22 deletions

View File

@ -1,5 +1,7 @@
package ba.steleks.storage; package ba.steleks.storage;
import ba.steleks.storage.error.exception.StorageException;
import ba.steleks.storage.error.exception.StorageFileNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource; import org.springframework.core.io.UrlResource;
@ -12,7 +14,6 @@ import java.net.MalformedURLException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.attribute.FileOwnerAttributeView;
import java.util.stream.Stream; import java.util.stream.Stream;
@Service @Service

View File

@ -0,0 +1,21 @@
package ba.steleks.storage.error;/**
* Created by ensar on 16/04/17.
*/
import ba.steleks.storage.error.exception.StorageFileNotFoundException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.logging.Logger;
@ControllerAdvice
public class StorageErrorHandler {
private static final Logger logger =
Logger.getLogger(StorageErrorHandler.class.getName());
@ExceptionHandler(StorageFileNotFoundException.class)
public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) {
return ResponseEntity.notFound().build();
}
}

View File

@ -1,4 +1,4 @@
package ba.steleks.storage; package ba.steleks.storage.error.exception;
public class StorageException extends RuntimeException { public class StorageException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package ba.steleks.storage; package ba.steleks.storage.error.exception;
public class StorageFileNotFoundException extends StorageException { public class StorageFileNotFoundException extends StorageException {

View File

@ -2,11 +2,10 @@ package ba.steleks.controller;
import ba.steleks.error.exception.ExternalServiceException; import ba.steleks.error.exception.ExternalServiceException;
import ba.steleks.model.Media; import ba.steleks.model.Media;
import ba.steleks.repository.EventsJpaRepository;
import ba.steleks.repository.MediaJpaRepository; import ba.steleks.repository.MediaJpaRepository;
import ba.steleks.service.Service; import ba.steleks.service.Service;
import ba.steleks.service.discovery.ServiceDiscoveryClient; import ba.steleks.service.discovery.ServiceDiscoveryClient;
import ba.steleks.storage.StorageFileNotFoundException;
import ba.steleks.storage.StorageService; import ba.steleks.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
@ -69,9 +68,4 @@ public class EventGalleryController {
return "redirect:/"; return "redirect:/";
} }
@ExceptionHandler(StorageFileNotFoundException.class)
public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) {
return ResponseEntity.notFound().build();
}
} }

View File

@ -5,7 +5,6 @@ import ba.steleks.model.TeamMedia;
import ba.steleks.repository.TeamsMediaJpaRepository; import ba.steleks.repository.TeamsMediaJpaRepository;
import ba.steleks.service.Service; import ba.steleks.service.Service;
import ba.steleks.service.discovery.ServiceDiscoveryClient; import ba.steleks.service.discovery.ServiceDiscoveryClient;
import ba.steleks.storage.StorageFileNotFoundException;
import ba.steleks.storage.StorageService; import ba.steleks.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
@ -70,9 +69,4 @@ public class TeamGalleryController {
return "redirect:/"; return "redirect:/";
} }
@ExceptionHandler(StorageFileNotFoundException.class)
public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) {
return ResponseEntity.notFound().build();
}
} }

View File

@ -5,7 +5,6 @@ import ba.steleks.model.User;
import ba.steleks.repository.UsersJpaRepository; import ba.steleks.repository.UsersJpaRepository;
import ba.steleks.service.Service; import ba.steleks.service.Service;
import ba.steleks.service.discovery.ServiceDiscoveryClient; import ba.steleks.service.discovery.ServiceDiscoveryClient;
import ba.steleks.storage.StorageFileNotFoundException;
import ba.steleks.storage.StorageService; import ba.steleks.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -62,9 +61,4 @@ public class ProfilePictureController {
return "redirect:/"; return "redirect:/";
} }
@ExceptionHandler(StorageFileNotFoundException.class)
public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) {
return ResponseEntity.notFound().build();
}
} }