* </ul>
* @return A file object pointing to the deployed file or null if there is no content
*/
@SuppressWarnings("unchecked")
private File determineDeploymentFile() {
Operation op = new ReadAttribute(getAddress(), "content");
Result result = getASConnection().execute(op);
List<Map<String, Object>> content = (List<Map<String, Object>>) result.getResult();
if (content == null || content.isEmpty()) {
// No content -> check for server group
if (path.startsWith(("server-group="))) {
// Server group has no content of its own - use the domain deployment
String name = path.substring(path.lastIndexOf("=") + 1);
op = new ReadResource(new Address("deployment", name));
result = getASConnection().execute(op);
if (result.isSuccess()) {
Map<String, Object> contentMap = (Map<String, Object>) result.getResult();
content = (List<Map<String, Object>>) contentMap.get("content");
if (content.get(0).containsKey("path")) {
String path = (String) content.get(0).get("path");
String relativeTo = (String) content.get(0).get("relative-to");
deploymentFile = getDeploymentFileFromPath(relativeTo, path);
} else if (content.get(0).containsKey("hash")) {
String base64Hash = ((Map<String, String>) content.get(0).get("hash")).get("BYTES_VALUE");
byte[] hash = Base64.decode(base64Hash);
ServerGroupComponent sgc = (ServerGroupComponent) context.getParentResourceComponent();
String baseDir = ((HostControllerComponent) sgc.context.getParentResourceComponent()).pluginConfiguration
.getSimpleValue("baseDir");
String contentPath = new File(baseDir, "/data/content").getAbsolutePath();
deploymentFile = getDeploymentFileFromHash(hash, contentPath);
}
return deploymentFile;
}
} else {
getLog().warn(
"Could not determine the location of the deployment - the content descriptor wasn't found for deployment"
+ getAddress() + ".");
return null;
}
}
Boolean archive = (Boolean) content.get(0).get("archive");
if (archive != null && !archive) {
getLog().debug("Exploded deployments not supported for retrieving the content.");
return null;
}
File deploymentFile = null;
if (content.get(0).containsKey("path")) {
String path = (String) content.get(0).get("path");
String relativeTo = (String) content.get(0).get("relative-to");
deploymentFile = getDeploymentFileFromPath(relativeTo, path);
} else if (content.get(0).containsKey("hash")) {
String base64Hash = ((Map<String, String>) content.get(0).get("hash")).get("BYTES_VALUE");
byte[] hash = Base64.decode(base64Hash);
Address contentPathAddress;
if (context.getParentResourceComponent() instanceof ManagedASComponent) {
// -> managed server we need to check for host=x/server=y, but the path brings host=x,server-config=y
String p = ((ManagedASComponent) context.getParentResourceComponent()).getPath();
p = p.replaceAll("server-config=", "server=");
contentPathAddress = new Address(p);
contentPathAddress.add("core-service", "server-environment");
} else {
// standalone
contentPathAddress = new Address("core-service", "server-environment");
}
op = new ReadAttribute(contentPathAddress, "content-dir");
result = getASConnection().execute(op);
String contentPath;
if (result.isSuccess()) {
contentPath = (String) result.getResult();