Source:
<code>private BundleHandoverResponse handleDeployment(BundleHandoverRequest request) { HandoverContentUploader contentUploader = new HandoverContentUploader(request, getASConnection()); boolean uploaded = contentUploader.upload(); if (!uploaded) { return contentUploader.getFailureResponse(); } Operation addDeploymentStep = new Operation("add", "deployment", contentUploader.getRuntimeName()); List<Object> addDeploymentContentProperty = new ArrayList<Object>(1); Map<String, Object> contentValues = new HashMap<String, Object>(); contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", contentUploader.getHash())); addDeploymentContentProperty.add(contentValues); addDeploymentStep.addAdditionalProperty("content", addDeploymentContentProperty); addDeploymentStep.addAdditionalProperty("name", contentUploader.getFilename()); addDeploymentStep.addAdditionalProperty("runtime-name", contentUploader.getRuntimeName()); Operation deployStep = new Operation("deploy", addDeploymentStep.getAddress()); CompositeOperation compositeOperation = new CompositeOperation(); compositeOperation.addStep(addDeploymentStep); compositeOperation.addStep(deployStep); <START> Result result = getASConnection().execute(compositeOperation, 300); <END> if (!result.isSuccess()) { return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription()); } else { return BundleHandoverResponse.success(); } }</code><technical_language>I this code fail (with JBAS014803: Duplicate resource) in case deployment existed AS7 server (which is deployed version 1 of bundle handedover deployment deploy version 2 of deployment file name content)</technical_language>

Target:
private BundleHandoverResponse handleDeployment(BundleHandoverRequest request) { HandoverContentUploader contentUploader = new HandoverContentUploader(request, getASConnection()); boolean uploaded = contentUploader.upload(); if (!uploaded) { return contentUploader.getFailureResponse(); } String filename = contentUploader.getFilename(); String runtimeName = contentUploader.getRuntimeName(); String hash = contentUploader.getHash(); Redeployer redeployer = new Redeployer(runtimeName, hash, getASConnection()); if (redeployer.deploymentExists()) { Result result = redeployer.redeployOnServer(); if (result.isRolledBack()) { return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription()); } return BundleHandoverResponse.success(); } Operation addDeploymentStep = new Operation("add", "deployment", runtimeName); List<Object> addDeploymentContentProperty = new ArrayList<Object>(1); Map<String, Object> contentValues = new HashMap<String, Object>(); contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", hash)); addDeploymentContentProperty.add(contentValues); addDeploymentStep.addAdditionalProperty("content", addDeploymentContentProperty); addDeploymentStep.addAdditionalProperty("name", filename); addDeploymentStep.addAdditionalProperty("runtime-name", runtimeName); Operation deployStep = new Operation("deploy", addDeploymentStep.getAddress()); CompositeOperation compositeOperation = new CompositeOperation(); compositeOperation.addStep(addDeploymentStep); compositeOperation.addStep(deployStep); Result result = getASConnection().execute(compositeOperation, 300); if (!result.isSuccess()) { return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription()); } else { return BundleHandoverResponse.success(); } }