import com.oransc.rappmanager.models.rappinstance.RappInstance;
import com.oransc.rappmanager.models.rappinstance.RappInstanceDeployOrder;
import com.oransc.rappmanager.models.rappinstance.RappInstanceState;
import com.oransc.rappmanager.models.rappinstance.RappInstance;
import com.oransc.rappmanager.models.rappinstance.RappInstanceDeployOrder;
import com.oransc.rappmanager.models.rappinstance.RappInstanceState;
import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachine;
import com.oransc.rappmanager.service.RappService;
import java.util.Map;
import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachine;
import com.oransc.rappmanager.service.RappService;
import java.util.Map;
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;
- return rappCacheService.getRapp(rappId).map(Rapp::getRappInstances).map(ResponseEntity::ok)
- .orElse(ResponseEntity.notFound().build());
+ return rappCacheService.getRapp(rappId).map(Rapp::getRappInstances).map(ResponseEntity::ok).orElseThrow(
+ () -> new RappHandlerException(HttpStatus.NOT_FOUND, "No instance found for rApp '" + rappId + "'."));
rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
rapp.getRappInstances().put(rappInstance.getRappInstanceId(), rappInstance);
return ResponseEntity.ok(rappInstance);
rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
rapp.getRappInstances().put(rappInstance.getRappInstanceId(), rappInstance);
return ResponseEntity.ok(rappInstance);
RappInstance rappInstance = rappPair.getLeft().getRappInstances().get(rappInstanceId);
rappInstance.setState(rappInstanceStateMachine.getRappInstanceState(rappInstanceId));
return rappInstance;
RappInstance rappInstance = rappPair.getLeft().getRappInstances().get(rappInstanceId);
rappInstance.setState(rappInstanceStateMachine.getRappInstanceState(rappInstanceId));
return rappInstance;
.filter(deployOrder -> deployOrder.equals(DeployOrder.DEPLOY))
.map(primeOrder -> rappService.deployRappInstance(rappPair.getLeft(), rappPair.getRight()))
.orElseGet(() -> rappService.undeployRappInstance(rappPair.getLeft(), rappPair.getRight())))
.filter(deployOrder -> deployOrder.equals(DeployOrder.DEPLOY))
.map(primeOrder -> rappService.deployRappInstance(rappPair.getLeft(), rappPair.getRight()))
.orElseGet(() -> rappService.undeployRappInstance(rappPair.getLeft(), rappPair.getRight())))
rappPair.getLeft().getRappInstances().get(rappInstanceId));
rappPair.getLeft().getRappInstances().remove(rappInstanceId);
return ResponseEntity.noContent().build();
rappPair.getLeft().getRappInstances().get(rappInstanceId));
rappPair.getLeft().getRappInstances().remove(rappInstanceId);
return ResponseEntity.noContent().build();