private function sanitizeAppRecord(& $record)
    {
        if (!is_array($record)) {
            throw new BadRequestException('Invalid App data provided');
        }

        if (!isset($record['name'])) {
            throw new BadRequestException('No App name provided in description.json');
        }

        if (!isset($record['type'])) {
            $record['type'] = AppTypes::NONE;
        }

        if (isset($record['active']) && !isset($record['is_active'])) {
            $record['is_active'] = $record['active'];
            unset($record['active']);
        } elseif (!isset($record['is_active'])) {
            $record['is_active'] = true;
        }

        if ($record['type'] === AppTypes::STORAGE_SERVICE) {
            if (!empty($serviceId = array_get($record, 'storage_service_id'))) {
                $fileServiceNames = ServiceManager::getServiceNamesByGroup(ServiceTypeGroups::FILE);
                $serviceName = ServiceManager::getServiceNameById($serviceId);
                if (!in_array($serviceName, $fileServiceNames)) {
                    throw new BadRequestException('Invalid Storage Service provided.');
                }
            } else {
                $record['storage_service_id'] = $this->getDefaultStorageServiceId();
            }

            if (!empty(array_get($record, 'storage_container'))) {
                $record['storage_container'] = trim($record['storage_container'], '/');
            } else {
                $record['storage_container'] = camelize($record['name']);
            }
        } else {
            $record['storage_service_id'] = null;
            $record['storage_container'] = null;
        }

        if (!isset($record['url'])) {
            $record['url'] = static::DEFAULT_URL;
        } else {
            $record['url'] = ltrim($record['url'], '/');
        }

        if (isset($record['path'])) {
            $record['path'] = ltrim($record['path'], '/');
        }

        if ($record['type'] === AppTypes::STORAGE_SERVICE || $record['type'] === AppTypes::PATH) {
            if (empty(array_get($record, 'path'))) {
                throw new BadRequestException('No Application Path provided in description.json');
            }
        } elseif ($record['type'] === AppTypes::URL) {
            if (empty(array_get($record, 'url'))) {
                throw new BadRequestException('No Application URL provided in description.json');
            }
        }
    }