import com.oransc.rappmanager.configuration.RappManagerConfiguration;
import com.oransc.rappmanager.models.cache.RappCacheService;
import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler;
import com.oransc.rappmanager.configuration.RappManagerConfiguration;
import com.oransc.rappmanager.models.cache.RappCacheService;
import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler;
import com.oransc.rappmanager.models.rapp.PrimeOrder;
import com.oransc.rappmanager.models.rapp.Rapp;
import com.oransc.rappmanager.models.rapp.RappPrimeOrder;
import com.oransc.rappmanager.models.rapp.PrimeOrder;
import com.oransc.rappmanager.models.rapp.Rapp;
import com.oransc.rappmanager.models.rapp.RappPrimeOrder;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
private final RappManagerConfiguration rappManagerConfiguration;
private final RappCacheService rappCacheService;
private final RappService rappService;
private final RappManagerConfiguration rappManagerConfiguration;
private final RappCacheService rappCacheService;
private final RappService rappService;
return ResponseEntity.ok(rappCacheService.getAllRapp());
}
@GetMapping("{rapp_id}")
public ResponseEntity<Rapp> getRapp(@PathVariable("rapp_id") String rappId) {
return ResponseEntity.ok(rappCacheService.getAllRapp());
}
@GetMapping("{rapp_id}")
public ResponseEntity<Rapp> getRapp(@PathVariable("rapp_id") String rappId) {
- return rappCacheService.getRapp(rappId).map(ResponseEntity::ok).orElse(ResponseEntity.badRequest().build());
+ return rappCacheService.getRapp(rappId).map(ResponseEntity::ok).orElseThrow(
+ () -> new RappHandlerException(HttpStatus.NOT_FOUND, String.format(RAPP_NOT_FOUND, rappId)));
return ResponseEntity.accepted().build();
} else {
logger.info("Invalid Rapp package for {}", rappId);
return ResponseEntity.accepted().build();
} else {
logger.info("Invalid Rapp package for {}", rappId);
.filter(primeOrder -> primeOrder.equals(PrimeOrder.PRIME))
.map(primeOrder -> rappService.primeRapp(rapp))
.orElseGet(() -> rappService.deprimeRapp(rapp)))
.filter(primeOrder -> primeOrder.equals(PrimeOrder.PRIME))
.map(primeOrder -> rappService.primeRapp(rapp))
.orElseGet(() -> rappService.deprimeRapp(rapp)))