@SuppressWarnings("incomplete-switch") public void validateLocation() { if (this.getStorageUri() != null) { if (!this.getStorageUri().validateLocationMode(this.locationMode)) { throw new UnsupportedOperationException(SR.STORAGE_URI_MISSING_LOCATION); } } // If the command only allows for a specific location, we should target // that location no matter what the retry policy says. switch (this.getRequestLocationMode()) { case PRIMARY_ONLY: if (this.getLocationMode() == LocationMode.SECONDARY_ONLY) { throw new IllegalArgumentException(SR.PRIMARY_ONLY_COMMAND); } this.setCurrentLocation(StorageLocation.PRIMARY); this.setLocationMode(LocationMode.PRIMARY_ONLY); break; case SECONDARY_ONLY: if (this.getLocationMode() == LocationMode.PRIMARY_ONLY) { throw new IllegalArgumentException(SR.SECONDARY_ONLY_COMMAND); } this.setCurrentLocation(StorageLocation.SECONDARY); this.setLocationMode(LocationMode.SECONDARY_ONLY); break; } this.getResult().setTargetLocation(this.currentLocation); }
@SuppressWarnings("incomplete-switch") public void validateLocation() { if (this.getStorageUri() != null) { if (!this.getStorageUri().validateLocationMode(this.locationMode)) { throw new UnsupportedOperationException(SR.STORAGE_URI_MISSING_LOCATION); } } // If the command only allows for a specific location, we should target // that location no matter what the retry policy says. switch (this.getRequestLocationMode()) { case PRIMARY_ONLY: if (this.getLocationMode() == LocationMode.SECONDARY_ONLY) { throw new IllegalArgumentException(SR.PRIMARY_ONLY_COMMAND); } this.setCurrentLocation(StorageLocation.PRIMARY); this.setLocationMode(LocationMode.PRIMARY_ONLY); break; case SECONDARY_ONLY: if (this.getLocationMode() == LocationMode.PRIMARY_ONLY) { throw new IllegalArgumentException(SR.SECONDARY_ONLY_COMMAND); } this.setCurrentLocation(StorageLocation.SECONDARY); this.setLocationMode(LocationMode.SECONDARY_ONLY); break; } this.getResult().setTargetLocation(this.currentLocation); }