public ServiceResponse<ReleaseId> updateContainerReleaseId(String id, ReleaseId releaseId) { if( releaseId == null ) { logger.error("Error updating releaseId for container '" + id + "'. ReleaseId is null."); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating releaseId for container " + id + ". ReleaseId is null. "); } try { KieContainerInstance kci = context.getContainer(id); // the following code is subject to a concurrent call to dispose(), but the cost of synchronizing it // would likely not be worth it. At this point a decision was made to fail the execution if a concurrent // call do dispose() is executed. if (kci != null && kci.getKieContainer() != null) { Results results = kci.getKieContainer().updateToVersion(releaseId); if (results.hasMessages(Level.ERROR)) { logger.error("Error updating releaseId for container " + id + " to version " + releaseId + "\nMessages: " + results.getMessages()); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating release id on container " + id + " to " + releaseId, kci.getResource().getReleaseId()); } else { return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.SUCCESS, "Release id successfully updated.", kci.getResource().getReleaseId()); } } else { return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Container " + id + " is not instantiated."); } } catch (Exception e) { logger.error("Error updating releaseId for container '" + id + "'", e); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating releaseId for container " + id + ": " + e.getClass().getName() + ": " + e.getMessage()); } }