protected File prepareArchive(String userSpecifedName, PackageDetailsKey key, ResourceType resourceType) {
//we're running in the agent. During the development of this functionality, there was
//a time when the deployment only worked from within the JBossAS server home.
//Further investigation never confirmed the problem again but since we have access to
//server home directory anyway, why not stay on the safe side... ;)
OutputStream os = null;
try {
File tempDir = createTempDirectory("teiid-deploy-content", null, getServerTempDirectory());
//The userSpecifiedName is used in case we renamed the file to add version.
File contentCopy = new File(tempDir, userSpecifedName);
os = new BufferedOutputStream(new FileOutputStream(contentCopy));
ContentContext contentContext = resourceContext.getContentContext();
ContentServices contentServices = contentContext.getContentServices();
contentServices.downloadPackageBitsForChildResource(contentContext, resourceType.getName(), key, os);
return contentCopy;
} catch (IOException e) {
throw new IllegalStateException("Failed to copy the deployed archive to destination.", e);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
getLog().warn("Failed to close the stream when copying deployment to destination.");
}
}
}