Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Change redeploy check, using deploy name instead of runtime-name
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvp8510 committed Nov 9, 2017
1 parent 980b136 commit 63ba33a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Expand Up @@ -303,7 +303,7 @@ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> package

// if none of undeploy/deploy conditions were met
if (result == null) {
Redeployer redeployer = new Redeployer(detail.getKey().getName(), hash, getASConnection());
Redeployer redeployer = new Redeployer(detail.getKey().getName(), null, hash, getASConnection());
result = redeployer.redeployOnServer();
}

Expand Down
Expand Up @@ -355,7 +355,7 @@ private BundleHandoverResponse handleDeployment(BundleHandoverRequest handoverRe
String runtimeName = contentUploader.getRuntimeName();
String hash = contentUploader.getHash();

Redeployer redeployer = new Redeployer(runtimeName, hash, getASConnection());
Redeployer redeployer = new Redeployer(filename, runtimeName, hash, getASConnection());
if (redeployer.deploymentExists()) {
Result result = redeployer.redeployOnServer();
if (result.isRolledBack()) {
Expand Down
Expand Up @@ -35,22 +35,24 @@
*/
class Redeployer {

private final String name;
private final String runtimeName;
private final String hash;
private final ASConnection connection;

Redeployer(String runtimeName, String hash, ASConnection connection) {
this.runtimeName = runtimeName;
Redeployer(String name, String runtimeName,String hash, ASConnection connection) {
this.name = name;
this.hash = hash;
this.connection = connection;
this.runtimeName = runtimeName;
}

boolean deploymentExists() {
Result deploymentResources = connection.execute(new ReadChildrenResources(new Address(), "deployment"));
for (Map.Entry<?, ?> deploymentResource : ((Map<?, ?>) deploymentResources.getResult()).entrySet()) {
@SuppressWarnings("unchecked")
Map<String, Object> deploymentResourceDetails = (Map<String, Object>) deploymentResource.getValue();
if (runtimeName.equals(deploymentResourceDetails.get("runtime-name"))) {
if (name.equals(deploymentResourceDetails.get("name"))) {
return true;
}
}
Expand All @@ -59,7 +61,10 @@ boolean deploymentExists() {

Result redeployOnServer() {
Operation op = new Operation("full-replace-deployment", new Address());
op.addAdditionalProperty("name", runtimeName);
op.addAdditionalProperty("name", name);
if (runtimeName != null) {
op.addAdditionalProperty("runtime-name", runtimeName);
}
List<Object> content = new ArrayList<Object>(1);
Map<String, Object> contentValues = new HashMap<String, Object>();
contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
Expand Down
Expand Up @@ -335,7 +335,7 @@ private BundleHandoverResponse handleDeployment(BundleHandoverRequest request) {
String runtimeName = contentUploader.getRuntimeName();
String hash = contentUploader.getHash();

Redeployer redeployer = new Redeployer(runtimeName, hash, getASConnection());
Redeployer redeployer = new Redeployer(filename, runtimeName, hash, getASConnection());
if (redeployer.deploymentExists()) {
Result result = redeployer.redeployOnServer();
if (result.isRolledBack()) {
Expand Down

0 comments on commit 63ba33a

Please sign in to comment.