diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsBundle.java b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsBundle.java
index e574d74b0..86b968299 100644
--- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsBundle.java
+++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsBundle.java
@@ -3,6 +3,8 @@
*/
package dev.galasa.cicsts.cicsresource;
+
+
/**
* Represents a CICS Bundle resource. It provides methods to set CICS Bundle specific attributes on the resource
* (via CEDA) and to manage and set attributes in CEMT
@@ -47,14 +49,15 @@ public interface ICicsBundle {
/**
* Return the CICS BUNDLE resource BUNDLEDIR attribute value
- * @return the resource JVMPROFILE attribute value
+ * @return the resource BundleDirectory
*/
public String getResourceDefinitionBundledirAttribute();
/**
- * Build the complete JVM server including the profile zOS UNIX file and the CICS resource definition. This method will install the CICS
+ * Build the complete CICS Bundle CICS resource definition. This method will install the CICS
* resource and wait for it to become enabled
* @throws CicsBundleResourceException
+ * @throws TestBundleResourceException
*/
public void build() throws CicsBundleResourceException;
@@ -186,5 +189,8 @@ public interface ICicsBundle {
* Returns the CICS BUNDLE name as defined in the CICS Resource Definition
* @return the CICS BUNDLE name
*/
- public String getName();
+ public String getDefinitionName();
+
+
+
}
diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsResource.java b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsResource.java
index 95f805026..1007f4cb8 100644
--- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsResource.java
+++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager/src/main/java/dev/galasa/cicsts/cicsresource/ICicsResource.java
@@ -15,6 +15,7 @@
*/
public interface ICicsResource {
+
/**
* Create a CICS BUNDLE resource object supplying the CICS bundle content.
*
@@ -26,11 +27,13 @@ public interface ICicsResource {
* @param name the CICS BUNDLE RDO name
* @param group the CICS BUNDLE RDO group name
* @param bundlePath the path to the directory in the test class bundle containing the CICS bundle
- * @param parameters substitution parameters to replace variables in the META-INF/cics.xml. Can be null
+ * @param bundleDir the path to an existing bundle already on zfs
+ * @param parameters substitution parameters to replace variables in the bundle parts
+ * @param skeletonType Velocity = 1, PlusPlus = 0
* @return the CICS Bundle object
* @throws CicsBundleResourceException
*/
- public ICicsBundle newCicsBundle(ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath, Map parameters) throws CicsBundleResourceException;
+ public ICicsBundle newCicsBundle(ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath,String bundleDir, Map parameters,int skeletonType) throws CicsBundleResourceException;
/**
* Create a CICS BUNDLE resource object without supplying the CICS bundle content, i.e. the bundle already exists on the zOS UNIX file system
@@ -102,4 +105,6 @@ public interface ICicsResource {
* @return the JVM profile
*/
public IJvmprofile newJvmprofile(String jvmprofileName, String content);
+
+
}
diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleImpl.java b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleImpl.java
index 51bad5670..cf14bffb1 100644
--- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleImpl.java
+++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleImpl.java
@@ -3,45 +3,23 @@
*/
package dev.galasa.cicsts.resource.internal;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
-import java.io.StringWriter;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.attribute.PosixFilePermissions;
import java.time.LocalDateTime;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
+import java.util.Iterator;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
+import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
import dev.galasa.artifact.IArtifactManager;
import dev.galasa.artifact.IBundleResources;
-import dev.galasa.artifact.ISkeletonProcessor.SkeletonType;
-import dev.galasa.artifact.TestBundleResourceException;
import dev.galasa.cicsts.CicstsHashMap;
import dev.galasa.cicsts.CicstsManagerException;
import dev.galasa.cicsts.ICicsRegion;
@@ -55,7 +33,6 @@
import dev.galasa.zos.IZosImage;
import dev.galasa.zosfile.IZosFileHandler;
import dev.galasa.zosfile.IZosUNIXFile;
-import dev.galasa.zosfile.IZosUNIXFile.UNIXFileDataType;
import dev.galasa.zosfile.ZosUNIXFileException;
public class CicsBundleImpl implements ICicsBundle {
@@ -73,14 +50,15 @@ public class CicsBundleImpl implements ICicsBundle {
private IZosFileHandler zosFileHandler;
private String localBundlePath;
private Map parameters = new HashMap<>();
- private boolean shouldDeploy;
- private List cicsBundleComponents = new ArrayList<>();
+ private boolean needsCopying;
+ private String bundleRoot;
private String resourceDefinitionName;
private String resourceDefinitionGroup;
private String resourceDefinitionDescription;
private CicsResourceStatus resourceDefinitionStatus = CicsResourceStatus.ENABLED;
private String resourceDefinitionBundledir;
+ private int skeletonType;
private int defaultTimeout;
@@ -88,7 +66,7 @@ public class CicsBundleImpl implements ICicsBundle {
private static final String RESOURCE_TYPE_BUNDLE = "BUNDLE";
- public CicsBundleImpl(CicsResourceManagerImpl cicsResourceManager, ICicsRegion cicsRegion, ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath, String bunndledir, Map parameters) throws CicsBundleResourceException {
+ public CicsBundleImpl(CicsResourceManagerImpl cicsResourceManager, ICicsRegion cicsRegion, ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath, String bunndledir, Map parameter,int skeletonType) throws CicsBundleResourceException {
this.cicsResourceManager = cicsResourceManager;
this.cicsResourceManager.registerCicsBundle(this);
this.artifactManager = this.cicsResourceManager.getArtifactManager();
@@ -103,31 +81,109 @@ public CicsBundleImpl(CicsResourceManagerImpl cicsResourceManager, ICicsRegion c
this.testClass = testClass;
this.resourceDefinitionName = name;
this.resourceDefinitionGroup = group;
+ this.skeletonType = skeletonType;
+ logger.debug("Creating CICS Bundle Directory");
try {
- this.runTemporaryUNIXPath = this.zosFileHandler.newUNIXFile(cicsRegion.getRunTemporaryUNIXDirectory().getUnixPath() + "CICSBundles" + SLASH_SYBMOL + getName() + SLASH_SYBMOL, this.cicsZosImage);
+ this.runTemporaryUNIXPath = this.zosFileHandler.newUNIXFile(cicsRegion.getRunTemporaryUNIXDirectory().getUnixPath() + "CICSBundles" + SLASH_SYBMOL , this.cicsZosImage);
} catch (CicstsManagerException | ZosUNIXFileException e) {
throw new CicsBundleResourceException("Unable to get run temporary UNIX path", e);
}
// CICS bundle source already stored on file system
if (bundlePath == null) {
- this.shouldDeploy = false;
+ this.needsCopying = false;
this.resourceDefinitionBundledir = bunndledir;
} else {
- this.shouldDeploy = true;
+ this.needsCopying = true;
if (bundlePath.endsWith(SLASH_SYBMOL)) {
this.localBundlePath = bundlePath;
} else {
this.localBundlePath = bundlePath + SLASH_SYBMOL;
}
- String root = new File(this.localBundlePath).getName();
- this.resourceDefinitionBundledir = this.runTemporaryUNIXPath.getUnixPath() + root + SLASH_SYBMOL;
- if (parameters != null && !parameters.isEmpty()) {
- this.parameters.putAll(parameters);
+ this.bundleRoot = new File(this.localBundlePath).getName();
+ this.resourceDefinitionBundledir = this.runTemporaryUNIXPath.getUnixPath() + this.bundleRoot + SLASH_SYBMOL;
+ logger.info("resourceDefinitionBundledir " + resourceDefinitionBundledir);
+
+
+ if (parameter != null && !parameter.isEmpty()) {
+ this.parameters.putAll(parameter);
}
- this.testBundleResources = this.artifactManager.getBundleResources(this.testClass);
+
+ Iterator> iterator = this.parameters.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = iterator.next();
+ logger.info("Parameter :" + entry.getKey() +" " + entry.getValue());
+ }
+ this.testBundleResources = this.artifactManager.getBundleResources(this.testClass);
}
}
+
+
+
+
+ public void copyBundleFilesToZfs() throws ZosUNIXFileException, IOException {
+ //No need to mess around parsing XML. Get the contents of the bundle directory and copy the files as per the resource type.
+ try {
+ Map dir;
+ //Copy to resourceDefinitionBundledir
+ dir = testBundleResources.retrieveDirectoryContents(localBundlePath);
+
+ Iterator> iterator = dir.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = iterator.next();
+
+ logger.info("File entry :" + entry.getKey());
+
+ //Get the file suffix
+ String fileExtension = null;
+ if(entry.getKey().contentEquals("cics.xml")) {
+ fileExtension = "cics.xml";
+ }
+ else {
+ fileExtension = FilenameUtils.getExtension(entry.getKey());
+ }
+ logger.info("fileExtension:" + fileExtension);
+ //Get the component type to get file transfer type
+ CicsBundleResourceType componentType = null;
+ try {
+ componentType = CicsBundleResourceType.valueOf(fileExtension.toUpperCase());
+ }
+ catch (IllegalArgumentException e) {
+ componentType = CicsBundleResourceType.valueOf("DEFAULT");
+ }
+ logger.info("File Type:"+ componentType);
+ logger.info("Copying file " + entry.getKey() + " to " + resourceDefinitionBundledir);
+
+ //Strip the directories in the Galasa resources directory to copy the bundle files to the resourceDefinitionBundledir correctly.
+ int endIndex = entry.getKey().indexOf(this.bundleRoot) + this.bundleRoot.length();;
+
+ StringBuilder stringBuilder = new StringBuilder(entry.getKey());
+ StringBuilder directory = stringBuilder.delete(0,endIndex);
+ String resource = directory.toString();
+ logger.info("Resource: "+ resource);
+
+ IZosUNIXFile bundleFile = this.zosFileHandler.newUNIXFile(resourceDefinitionBundledir + resource, cicsZosImage);
+ if (!bundleFile.exists()) {
+ logger.info("Setting permissions");
+ bundleFile.create(PosixFilePermissions.fromString("rwxrwxrwx"));
+ }
+ if (componentType.isBinaryBundleResource()) {
+ logger.info("Copying binary file");
+ bundleFile.storeBinary(IOUtils.toByteArray(this.testBundleResources.retrieveSkeletonFile(entry.getKey(), this.parameters),this.skeletonType));
+ } else {
+ //Convert the byte array to String and substitute the variables
+ logger.info("Copying text file");
+ String s = new String(IOUtils.toByteArray(this.testBundleResources.retrieveSkeletonFile(entry.getKey(), this.parameters),this.skeletonType), StandardCharsets.UTF_8);
+ bundleFile.storeText(s);
+ }
+ }
+ } catch (Exception e) {
+ logger.debug("Failure in copying bundle files to zFS");
+ e.printStackTrace();
+ }
+ logger.info("Exiting copy of bundle files");
+ }
+
@Override
public void setDefinitionDescriptionAttribute(String value) {
this.resourceDefinitionDescription = value;
@@ -167,14 +223,14 @@ public String getResourceDefinitionBundledirAttribute() {
public void buildResourceDefinition() throws CicsBundleResourceException {
try {
if (resourceDefined()) {
- throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getName() + " already exists");
+ throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " already exists");
}
boolean setUcctran = false;
if (this.cicsTerminal.isUppercaseTranslation() == true) {
this.cicsTerminal.setUppercaseTranslation(false);
setUcctran = true;
}
- this.cicsRegion.ceda().createResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), getResourceDefinitionGroupAttribute(), buildResourceParameters());
+ this.cicsRegion.ceda().createResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), getResourceDefinitionGroupAttribute(), buildResourceParameters());
if (setUcctran) {
this.cicsTerminal.setUppercaseTranslation(true);
}
@@ -187,134 +243,13 @@ public void buildResourceDefinition() throws CicsBundleResourceException {
}
}
- @Override
- public void deploy() throws CicsBundleResourceException {
- if (!this.shouldDeploy) {
- throw new CicsBundleResourceException("The CICS bundle content was not supplied when the ICicsBundle was created");
- }
- try {
- findComponents();
- for (CicsBundleComponent bundleComponent : this.cicsBundleComponents) {
- logger.debug("Copying file " + bundleComponent.localPath + " to " + bundleComponent.targetPath);
-
- IZosUNIXFile bundleFile = this.zosFileHandler.newUNIXFile(bundleComponent.targetPath, cicsZosImage);
- if (bundleComponent.type.isBinaryBundleResource()) {
- bundleFile.setDataType(UNIXFileDataType.BINARY);
- } else {
- bundleFile.setDataType(UNIXFileDataType.TEXT);
- }
- if (!bundleFile.exists()) {
- bundleFile.create(PosixFilePermissions.fromString("rwxrwxrwx"));
- }
- bundleFile.storeBinary(bundleComponent.content);
- }
- } catch (ZosUNIXFileException e) {
- throw new CicsBundleResourceException("Problem deploying CICS bundle to zOS UNIX file system", e);
- }
- }
- private void findComponents() throws CicsBundleResourceException {
- try {
- String localPath = this.localBundlePath + "META-INF/cics.xml";
- String targetPath = this.getResourceDefinitionBundledirAttribute() + "META-INF/cics.xml";
- byte[] content = IOUtils.toByteArray(this.testBundleResources.retrieveSkeletonFile(localPath, this.parameters, SkeletonType.VELOCITY));
- CicsBundleComponent cicsBundleComponent = new CicsBundleComponent(localPath, targetPath, content, CicsBundleResourceType.CICSXML);
- this.cicsBundleComponents.add(cicsBundleComponent);
- NodeList nodes = getDocument(cicsBundleComponent).getElementsByTagName("define");
- for (int i = 0; i < nodes.getLength(); i++) {
- NamedNodeMap attributes = nodes.item(i).getAttributes();
- String type = attributes.getNamedItem("type").getNodeValue();
- String path = attributes.getNamedItem("path").getNodeValue();
- localPath = this.localBundlePath + path;
- targetPath = getResourceDefinitionBundledirAttribute() + path;
- content = IOUtils.toByteArray(this.testBundleResources.retrieveSkeletonFile(localPath, this.parameters, SkeletonType.VELOCITY));
- CicsBundleResourceType componentType = CicsBundleResourceType.valueOf(new File(type).getName());
- cicsBundleComponent = new CicsBundleComponent(localPath, targetPath, content, componentType);
- this.cicsBundleComponents.add(cicsBundleComponent);
- if (componentType.getSubComponentType() != null) {
- parseCicsBundleComponent(cicsBundleComponent);
- }
- }
- } catch (CicsBundleResourceException | TestBundleResourceException | IOException e) {
- throw new CicsBundleResourceException("Problem retrieving the CICS bundle files from the test bundle", e);
- }
- }
- private void parseCicsBundleComponent(CicsBundleComponent cicsBundleComponent) throws CicsBundleResourceException {
- try {
- NodeList nodes = getDocument(cicsBundleComponent).getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- String localPath;
- String targetPath;
- byte[] content;
-
- Element element = (Element) nodes.item(i);
- String nodeName = element.getTagName();
- String symbolicName = element.getAttribute("symbolicname");
- if (nodeName.equals("osgibundle")) {
- String version = element.getAttribute("version");
- String fileName = symbolicName + "_" + version + ".jar";
- localPath = this.localBundlePath + fileName;
- targetPath = getResourceDefinitionBundledirAttribute() + fileName;
- content = IOUtils.toByteArray(this.testBundleResources.retrieveJar(symbolicName, version, this.localBundlePath));
- } else if (nodeName.equals("nodejsapp")) {
- //TODO !!??
- throw new CicsBundleResourceException("nodejsapp not yet implemented");
- } else {
- String fileName = symbolicName + "." + cicsBundleComponent.type.getSubComponentType().toString().toLowerCase();
- localPath = this.localBundlePath + fileName;
- targetPath = getResourceDefinitionBundledirAttribute() + fileName;
- content = IOUtils.toByteArray(this.testBundleResources.retrieveFile(localPath));
- }
- this.cicsBundleComponents.add(new CicsBundleComponent(localPath, targetPath , content, cicsBundleComponent.type.getSubComponentType()));
- }
- } catch (CicsBundleResourceException | TestBundleResourceException | IOException e) {
- throw new CicsBundleResourceException("Problem parsing bundle component", e);
- }
- }
-
- private Document getDocument(CicsBundleComponent cicsBundleComponent) throws CicsBundleResourceException {
- try {
- logger.trace("Parsing " + cicsBundleComponent.localPath);
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(cicsBundleComponent.content));
- logger.debug("Content:" + "\n" + documentToString(document));
- return document;
- } catch (SAXException | IOException | ParserConfigurationException e) {
- throw new CicsBundleResourceException("Problem retrieving content of \"" + cicsBundleComponent.localPath + "\" from the test bundle", e);
- }
- }
-
- protected String documentToString(Document document) throws CicsBundleResourceException {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- // Remove blank lines
- document.normalize();
- XPath xPath = XPathFactory.newInstance().newXPath();
- NodeList nodeList = (NodeList) xPath.evaluate("//text()[normalize-space()='']", document, XPathConstants.NODESET);
- for (int i = 0; i < nodeList.getLength(); ++i) {
- Node node = nodeList.item(i);
- node.getParentNode().removeChild(node);
- }
-
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- Source source = new DOMSource(document);
- StringWriter stringWriter = new StringWriter();
- StreamResult result = new StreamResult(stringWriter);
- transformer.transform(source, result);
- return stringWriter.toString();
- } catch (XPathExpressionException | TransformerException e) {
- throw new CicsBundleResourceException("Unable to convert server.xml org.w3c.dom.Document to java.lang.String");
- }
- }
@Override
public void buildInstallResourceDefinition() throws CicsBundleResourceException {
buildResourceDefinition();
- if (this.shouldDeploy) {
+ if (this.needsCopying) {
deploy();
}
installResourceDefinition();
@@ -324,10 +259,9 @@ public void buildInstallResourceDefinition() throws CicsBundleResourceException
public void installResourceDefinition() throws CicsBundleResourceException {
try {
if (resourceInstalled()) {
- throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getName() + " already installed");
+ throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " already installed");
}
- this.cicsRegion.ceda().installResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), this.resourceDefinitionGroup);
- //TODO: should return messages????
+ this.cicsRegion.ceda().installResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), this.resourceDefinitionGroup);
if (!resourceInstalled()) {
throw new CicsBundleResourceException("Failed to install " + RESOURCE_TYPE_BUNDLE + " resource definition");
}
@@ -339,7 +273,7 @@ public void installResourceDefinition() throws CicsBundleResourceException {
@Override
public boolean resourceDefined() throws CicsBundleResourceException {
try {
- return this.cicsRegion.ceda().resourceExists(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), resourceDefinitionGroup);
+ return this.cicsRegion.ceda().resourceExists(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), resourceDefinitionGroup);
} catch (CicstsManagerException e) {
throw new CicsBundleResourceException("Unable to display " + RESOURCE_TYPE_BUNDLE + " resource definition", e);
}
@@ -348,7 +282,7 @@ public boolean resourceDefined() throws CicsBundleResourceException {
@Override
public boolean resourceInstalled() throws CicsBundleResourceException {
try {
- return this.cicsRegion.cemt().inquireResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName()) != null;
+ return this.cicsRegion.cemt().inquireResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName()) != null;
} catch (CicstsManagerException e) {
throw new CicsBundleResourceException("Unable to inquire " + RESOURCE_TYPE_BUNDLE + "", e);
}
@@ -358,11 +292,11 @@ public boolean resourceInstalled() throws CicsBundleResourceException {
public void enable() throws CicsBundleResourceException {
try {
if (!resourceInstalled()) {
- throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getName() + " does not exist");
+ throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " does not exist");
}
- this.cicsRegion.cemt().setResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), "ENABLED");
+ this.cicsRegion.cemt().setResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), "ENABLED");
} catch (CicstsManagerException e) {
- throw new CicsBundleResourceException("Problem enabling " + RESOURCE_TYPE_BUNDLE + " " + getName(), e);
+ throw new CicsBundleResourceException("Problem enabling " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName(), e);
}
}
@@ -373,7 +307,7 @@ public boolean waitForEnable() throws CicsBundleResourceException {
@Override
public boolean waitForEnable(int timeout) throws CicsBundleResourceException {
- logger.trace("Waiting " + timeout + " second(s) for " + RESOURCE_TYPE_BUNDLE + " " + getName() + " to be enabled");
+ logger.trace("Waiting " + timeout + " second(s) for " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " to be enabled");
LocalDateTime timeoutTime = LocalDateTime.now().plusSeconds(timeout);
while (LocalDateTime.now().isBefore(timeoutTime)) {
if (isEnabled()) {
@@ -395,9 +329,9 @@ public boolean isEnabled() throws CicsBundleResourceException {
}
boolean enabled = cemtInquire().isParameterEquals("enablestatus", CicsResourceStatus.ENABLED.toString());
if (enabled) {
- logger.trace(RESOURCE_TYPE_BUNDLE + " " + getName() + " is enabled");
+ logger.trace(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " is enabled");
} else {
- logger.trace(RESOURCE_TYPE_BUNDLE + " " + getName() + " is NOT enabled");
+ logger.trace(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " is NOT enabled");
}
return enabled;
}
@@ -406,11 +340,11 @@ public boolean isEnabled() throws CicsBundleResourceException {
public boolean disable() throws CicsBundleResourceException {
try {
if (!resourceInstalled()) {
- throw new CicsJvmserverResourceException(RESOURCE_TYPE_BUNDLE + " " + getName() + " does not exist");
+ throw new CicsJvmserverResourceException(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " does not exist");
}
- this.cicsRegion.cemt().setResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), "DISABLED");
+ this.cicsRegion.cemt().setResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), "DISABLED");
} catch (CicstsManagerException e) {
- throw new CicsBundleResourceException("Problem disabling " + RESOURCE_TYPE_BUNDLE + " " + getName(), e);
+ throw new CicsBundleResourceException("Problem disabling " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName(), e);
}
return isEnabled();
}
@@ -422,7 +356,7 @@ public boolean waitForDisable() throws CicsBundleResourceException {
@Override
public boolean waitForDisable(int timeout) throws CicsBundleResourceException {
- logger.trace("Waiting " + timeout + " second(s) for " + RESOURCE_TYPE_BUNDLE + " " + getName() + " to be disabled");
+ logger.trace("Waiting " + timeout + " second(s) for " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " to be disabled");
LocalDateTime timeoutTime = LocalDateTime.now().plusSeconds(timeout);
while (LocalDateTime.now().isBefore(timeoutTime)) {
if (!isEnabled()) {
@@ -435,7 +369,7 @@ public boolean waitForDisable(int timeout) throws CicsBundleResourceException {
}
}
if (isEnabled()) {
- throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getName() + " not disabled in " + timeout + " second(s)");
+ throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " not disabled in " + timeout + " second(s)");
}
return true;
}
@@ -458,10 +392,10 @@ public boolean disableDiscardInstall(int timeout) throws CicsBundleResourceExcep
public void delete() throws CicsBundleResourceException {
try {
if (resourceDefined()) {
- this.cicsRegion.ceda().deleteResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName(), resourceDefinitionGroup);
+ this.cicsRegion.ceda().deleteResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName(), resourceDefinitionGroup);
}
} catch (CicstsManagerException e) {
- throw new CicsBundleResourceException("Problem deleteing " + RESOURCE_TYPE_BUNDLE + " " + getName(), e);
+ throw new CicsBundleResourceException("Problem deleteing " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName(), e);
}
}
@@ -469,13 +403,13 @@ public void delete() throws CicsBundleResourceException {
public void discard() throws CicsBundleResourceException {
try {
if (resourceInstalled()) {
- this.cicsRegion.cemt().discardResource(cicsTerminal, RESOURCE_TYPE_BUNDLE, getName());
+ this.cicsRegion.cemt().discardResource(cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName());
if (resourceInstalled()) {
- throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " was not discarded" + getName());
+ throw new CicsBundleResourceException(RESOURCE_TYPE_BUNDLE + " was not discarded" + getDefinitionName());
}
}
} catch (CicstsManagerException e) {
- throw new CicsBundleResourceException("Problem discarding " + RESOURCE_TYPE_BUNDLE + " " + getName(), e);
+ throw new CicsBundleResourceException("Problem discarding " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName(), e);
}
}
@@ -490,24 +424,28 @@ public void disableDiscardDelete() throws CicsBundleResourceException {
@Override
public void build() throws CicsBundleResourceException {
try {
- if (this.shouldDeploy) {
- deploy();
+ if (this.needsCopying) {
+ try {
+ copyBundleFilesToZfs();
+ } catch (ZosUNIXFileException | IOException e) {
+ throw new CicsBundleResourceException("Problem copying bundle files to zFS", e);
+ }
}
buildResourceDefinition();
installResourceDefinition();
} catch (CicsBundleResourceException e) {
- throw new CicsBundleResourceException("Problem building " + RESOURCE_TYPE_BUNDLE + " " + getName(), e);
+ throw new CicsBundleResourceException("Problem building " + RESOURCE_TYPE_BUNDLE + " " + getDefinitionName(), e);
}
}
@Override
- public String getName() {
+ public String getDefinitionName() {
return this.resourceDefinitionName;
}
@Override
public String toString() {
- return "[CICS Bundle] " + getName();
+ return "[CICS Bundle] " + getDefinitionName();
}
protected int getDefaultTimeout() throws CicsBundleResourceException {
@@ -541,13 +479,13 @@ protected StringBuilder appendNotNull(StringBuilder resourceParameters, String a
protected CicstsHashMap cemtInquire() throws CicsBundleResourceException {
if (!resourceInstalled()) {
- throw new CicsBundleResourceException("JVMSERVER " + getName() + " does not exist");
+ throw new CicsBundleResourceException("CICS Bundle " + getDefinitionName() + " does not exist");
}
CicstsHashMap cemtMap;
try {
- cemtMap = this.cicsRegion.cemt().inquireResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getName());
+ cemtMap = this.cicsRegion.cemt().inquireResource(this.cicsTerminal, RESOURCE_TYPE_BUNDLE, getDefinitionName());
} catch (CicstsManagerException e) {
- throw new CicsBundleResourceException("Problem inquiring JVMSERVER " + getName(), e);
+ throw new CicsBundleResourceException("Problem inquiring CICS Bundle " + getDefinitionName(), e);
}
return cemtMap;
}
@@ -555,7 +493,7 @@ protected CicstsHashMap cemtInquire() throws CicsBundleResourceException {
protected void cleanup() {
try {
if (!resourceInstalled()) {
- logger.info(RESOURCE_TYPE_BUNDLE + " " + getName() + " has not been installed");
+ logger.info(RESOURCE_TYPE_BUNDLE + " " + getDefinitionName() + " has not been installed");
} else {
try {
disable();
@@ -578,19 +516,26 @@ protected void cleanup() {
logger.error("Problem in cleanup phase", e);
}
}
-
- private class CicsBundleComponent {
-
- private String localPath;
- private String targetPath;
- private byte[] content;
- private CicsBundleResourceType type;
-
- private CicsBundleComponent(String localPath, String targetPath, byte[] content, CicsBundleResourceType type) {
- this.localPath = localPath;
- this.targetPath = targetPath;
- this.content = content;
- this.type = type;
+
+
+ @Override
+ public void deploy() throws CicsBundleResourceException {
+ if (!this.needsCopying) {
+ throw new CicsBundleResourceException("The CICS bundle content was not supplied when the ICicsBundle was created");
+ }
+ try {
+ copyBundleFilesToZfs();
+ } catch (ZosUNIXFileException e) {
+ throw new CicsBundleResourceException("Problem deploying CICS bundle to zOS UNIX file system", e);
+ } catch (IOException e) {
+ logger.debug("Unexpected error deploying CICS Bundle");
+ e.printStackTrace();
}
}
+
+
+
+
+
+
}
diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleResourceType.java b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleResourceType.java
index b0ad7b621..6ee0133db 100644
--- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleResourceType.java
+++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsBundleResourceType.java
@@ -183,7 +183,13 @@ public enum CicsBundleResourceType {
/**
* DB2 PACKAGESET
*/
- PACKAGESET(true);
+ PACKAGESET(true),
+
+ /**
+ * DEFAULT if not found
+ */
+ DEFAULT();
+
private boolean binaryBundleResource = true;
private CicsBundleResourceType subComponentType = null;
diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsResourceImpl.java b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsResourceImpl.java
index 6a4f5e983..9c8e938d7 100644
--- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsResourceImpl.java
+++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.resource.manager/src/main/java/dev/galasa/cicsts/resource/internal/CicsResourceImpl.java
@@ -36,15 +36,18 @@ public CicsResourceImpl(CicsResourceManagerImpl cicsResourceManagerImpl, ICicsRe
throw new CicsResourceManagerException("Unable to get zOS File Handler", e);
}
}
+
+
+
@Override
- public ICicsBundle newCicsBundle(ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath, Map parameters) throws CicsBundleResourceException {
- return new CicsBundleImpl(this.cicsResourceManagerImpl, this.cicsRegion, cicsTerminal, testClass, name, group, bundlePath, null, parameters);
+ public ICicsBundle newCicsBundle(ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundlePath,String bundleDirectory, Map parameters,int skeletonType) throws CicsBundleResourceException {
+ return new CicsBundleImpl(this.cicsResourceManagerImpl, this.cicsRegion, cicsTerminal, testClass, name, group, bundlePath, bundleDirectory, parameters,skeletonType);
}
@Override
public ICicsBundle newCicsBundle(ICicsTerminal cicsTerminal, Class> testClass, String name, String group, String bundleDir) throws CicsBundleResourceException {
- return new CicsBundleImpl(this.cicsResourceManagerImpl, this.cicsRegion, cicsTerminal, testClass, name, group, null, bundleDir, null);
+ return new CicsBundleImpl(this.cicsResourceManagerImpl, this.cicsRegion, cicsTerminal, testClass, name, group, null, bundleDir, null, 0);
}
@Override