|
52 | 52 | import org.openhab.core.io.rest.RESTConstants; |
53 | 53 | import org.openhab.core.io.rest.RESTResource; |
54 | 54 | import org.openhab.core.io.rest.core.config.ConfigurationService; |
55 | | -import org.openhab.core.io.rest.core.persistence.PersistenceItemNotFoundException; |
56 | 55 | import org.openhab.core.items.Item; |
57 | 56 | import org.openhab.core.items.ItemNotFoundException; |
58 | 57 | import org.openhab.core.items.ItemRegistry; |
|
65 | 64 | import org.openhab.core.persistence.ModifiablePersistenceService; |
66 | 65 | import org.openhab.core.persistence.PersistenceItemConfiguration; |
67 | 66 | import org.openhab.core.persistence.PersistenceItemInfo; |
| 67 | +import org.openhab.core.persistence.PersistenceItemNotFoundException; |
68 | 68 | import org.openhab.core.persistence.PersistenceManager; |
69 | 69 | import org.openhab.core.persistence.PersistenceService; |
70 | 70 | import org.openhab.core.persistence.PersistenceServiceProblem; |
@@ -625,11 +625,15 @@ private List<PersistenceServiceDTO> getPersistenceServiceList(Locale locale) { |
625 | 625 |
|
626 | 626 | private Response getServiceItemListDTO(@Nullable String serviceId, @Nullable String itemName) { |
627 | 627 | // If serviceId is null, then use the default service |
628 | | - PersistenceService service; |
629 | 628 | String effectiveServiceId = serviceId != null ? serviceId : persistenceServiceRegistry.getDefaultId(); |
630 | | - service = effectiveServiceId != null ? persistenceServiceRegistry.get(effectiveServiceId) : null; |
631 | 629 |
|
632 | | - if (effectiveServiceId == null || service == null) { |
| 630 | + if (effectiveServiceId == null) { |
| 631 | + logger.debug("No default persistence service."); |
| 632 | + return JSONResponse.createErrorResponse(Status.NOT_FOUND, "No default persistence service."); |
| 633 | + } |
| 634 | + |
| 635 | + PersistenceService service = persistenceServiceRegistry.get(effectiveServiceId); |
| 636 | + if (service == null) { |
633 | 637 | logger.debug("Persistence service not found '{}'.", effectiveServiceId); |
634 | 638 | return JSONResponse.createErrorResponse(Status.NOT_FOUND, |
635 | 639 | "Persistence service not found: " + effectiveServiceId); |
@@ -666,7 +670,7 @@ protected Set<PersistenceItemInfoDTO> createDTO(QueryablePersistenceService qSer |
666 | 670 | String alias = itemToAlias.get(itemName); |
667 | 671 | PersistenceItemInfo singleItemInfo = qService.getItemInfo(itemName, alias); |
668 | 672 | if (singleItemInfo == null) { |
669 | | - throw new PersistenceItemNotFoundException(itemName, serviceId); |
| 673 | + throw new PersistenceItemNotFoundException(serviceId, itemName, alias); |
670 | 674 | } |
671 | 675 | itemInfo = Set.of(singleItemInfo); |
672 | 676 | } else { |
|
0 commit comments