class CreateNetworkCollection {

    public void buildNetworkCollectionName(BuildingBlockExecution execution) throws Exception {
        try {
            ServiceInstance serviceInstance =
                    extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
            InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
            if (instanceGroup.getModelInfoInstanceGroup() != null) {
                // Build collection name assembling SI name and IG function
                if (serviceInstance.getServiceInstanceName() != null
                        && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) {
                    String networkCollectionName = serviceInstance.getServiceInstanceName().concat(UNDERSCORE)
                            .concat(instanceGroup.getModelInfoInstanceGroup().getFunction());
                    // set networkCollectionName object on execution to be re-used within current BB
                    execution.setVariable(NETWORK_COLLECTION_NAME, networkCollectionName);
                } else {
                    throw new IllegalArgumentException(
                            "Cannot generate collection name because either one or both fields are null: "
                                    + " Service Instance Name: " + serviceInstance.getServiceInstanceName()
                                    + ", Instance Group Function: "
                                    + instanceGroup.getModelInfoInstanceGroup().getFunction());
                }
            } else {
                throw new IllegalArgumentException("Instance group model info is null");
            }
        } catch (Exception ex) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    }

}