/** * @name createProduct * @description Method is used in provisioning of service to create the product for bugzilla by * taking the service_instance as a name whenever the product is created at the same time with * same name the group for that product is created by bugzilla internally * @param productName * @return Product * @throws IOException */ public Product createProduct(String productName) throws IOException { if (getBugzillaProduct(productName).getProducts() != null && getBugzillaProduct(productName).getProducts().size() != 0) { updateProductGroup(productName); return getBugzillaProduct(productName).getProducts().get(0); } Product bugzillaProduct = new Product(); setProperties(); try { logger.info( "Bugzilla getBugzillaResource().getBugzillaServer() " + getBugzillaResource().getBugzillaServer()); url = new URI(REST_PRODUCT_URL); MultiValueMap<String, String> productData = new LinkedMultiValueMap<String, String>(); productData.add("name", productName); productData.add("description", productName + " as description"); productData.add("version", "1.0"); HttpEntity<?> requestEntity = new HttpEntity<Object>(productData, createHeaders()); ResponseEntity<String> responseEntity = getRestTemplate().exchange(url, HttpMethod.POST, requestEntity, String.class); ObjectMapper mapper = new ObjectMapper(); bugzillaProduct = mapper.readValue(responseEntity.getBody(), Product.class); logger.info("Bugzilla Product Created " + bugzillaProduct.getId()); if (bugzillaProduct.getId() != null) { bugzillaProduct = getBugzillaProduct(productName).getProducts().get(0); updateProductGroup(productName); } } catch (Exception e) { e.printStackTrace(); } return bugzillaProduct; }
/** * @name createProduct * @description Method is used in provisioning of service to create the product for bugzilla by * taking the service_instance as a name whenever the product is created at the same time with * same name the group for that product is created by bugzilla internally * @param productName * @return Product * @throws IOException */ public Product createComponent(String productName) throws IOException { Product bugzillaProduct = new Product(); setProperties(); try { url = new URI(REST_COMPONENT_URL); MultiValueMap<String, String> componentData = new LinkedMultiValueMap<String, String>(); componentData.add("product", productName); componentData.add("name", "New " + productName); componentData.add("description", productName + " as description"); // componentData.add("default_assignee", "*****@*****.**"); componentData.add("default_assignee", "admin@" + productName + ".com"); HttpEntity<?> requestEntity = new HttpEntity<Object>(componentData, createHeaders()); ResponseEntity<String> responseEntity = getRestTemplate().exchange(url, HttpMethod.POST, requestEntity, String.class); ObjectMapper mapper = new ObjectMapper(); bugzillaProduct = mapper.readValue(responseEntity.getBody(), Product.class); logger.info("Bugzilla Product Created " + bugzillaProduct.getId()); } catch (Exception e) { e.printStackTrace(); } return bugzillaProduct; }