private State.Builder changeStatusToFrom(PendingStatus newStatus, PendingStatus... validPendingStatuses) {
State currentState = this.state;
- checkState(Arrays.stream(validPendingStatuses).anyMatch(s -> s == currentState.getPendingInstallationStatus()),
- "Can't move to %s when status is %s (should be any of %s)",
- newStatus, currentState.getPendingInstallationStatus(), Arrays.toString(validPendingStatuses));
+ if (Arrays.stream(validPendingStatuses).noneMatch(s -> s == currentState.getPendingInstallationStatus())) {
+ throw new IllegalStateException(String.format("Can't move to %s when status is %s (should be any of %s)",
+ newStatus, currentState.getPendingInstallationStatus(), Arrays.toString(validPendingStatuses)));
+ }
+
return State.newBuilder(currentState, newStatus);
}
@Override
public void define(WebService.NewController controller) {
- WebService.NewAction action = controller.createAction("clear_error_message")
+ controller.createAction("clear_error_message")
.setSince("6.7")
.setPost(true)
.setDescription("Clear error message of last install of an edition (if any). Require 'Administer System' permission.")
FileUtils.deleteDirectory(downloadDir);
Files.move(tmpDir, downloadDir);
} catch (IOException e) {
- throw new RuntimeException(e.getMessage(), e);
+ throw new IllegalStateException(e.getMessage(), e);
} finally {
FileUtils.deleteQuietly(tmpDir);
}