BundleDeployment newDeployment = entityManager.find(BundleDeployment.class, bundleDeploymentId);
if (null == newDeployment) {
throw new IllegalArgumentException("Invalid bundleDeploymentId: " + bundleDeploymentId);
}
BundleDestination destination = newDeployment.getDestination();
ResourceGroup group = destination.getGroup();
// Create and persist updates for each of the group members.
Set<Resource> groupMembers = group.getExplicitResources();
if (groupMembers.isEmpty()) {
throw new IllegalArgumentException("Destination [" + destination
+ "] group has no members. Invalid deployment destination");
}
checkDeployBundleAuthz(subject, newDeployment.getBundleVersion().getBundle().getId(), group.getId());
for (Resource groupMember : groupMembers) {
try {
scheduleBundleResourceDeployment(subject, newDeployment, groupMember, isCleanDeployment, isRevert);
} catch (Throwable t) {
LOG.error("Failed to complete scheduling of bundle deployment to [" + groupMember
+ "]. Other bundle deployments to other resources may have been scheduled. ", t);
}
}
// make sure the new deployment is set as the live deployment and properly replaces the
// previously live deployment.
destination = entityManager.find(BundleDestination.class, destination.getId());
List<BundleDeployment> currentDeployments = destination.getDeployments();
if (null != currentDeployments) {
for (BundleDeployment d : currentDeployments) {
if (d.isLive()) {
d.setLive(false);
if (!isRevert) {