Search in sources :

Example 11 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogService method getCloudbreakDefaultImageCatalog.

private ImageCatalog getCloudbreakDefaultImageCatalog() {
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.setImageCatalogName(CLOUDBREAK_DEFAULT_CATALOG_NAME);
    imageCatalog.setImageCatalogUrl(defaultCatalogUrl);
    imageCatalog.setPublicInAccount(true);
    return imageCatalog;
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 12 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogService method getAllPublicInAccount.

public Iterable<ImageCatalog> getAllPublicInAccount() {
    IdentityUser cbUser = authenticatedUserService.getCbUser();
    List<ImageCatalog> allPublicInAccount = imageCatalogRepository.findAllPublicInAccount(cbUser.getUserId(), cbUser.getAccount());
    allPublicInAccount.add(getCloudbreakDefaultImageCatalog());
    return allPublicInAccount;
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 13 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogService method update.

public ImageCatalog update(ImageCatalog source) {
    ImageCatalog imageCatalog = imageCatalogRepository.findOne(source.getId());
    authorizationService.hasReadPermission(imageCatalog);
    checkImageCatalog(imageCatalog, source.getId());
    imageCatalog.setImageCatalogName(source.getImageCatalogName());
    imageCatalog.setImageCatalogUrl(source.getImageCatalogUrl());
    return create(imageCatalog);
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 14 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogService method get.

public ImageCatalog get(Long id) {
    ImageCatalog imageCatalog;
    IdentityUser user = authenticatedUserService.getCbUser();
    imageCatalog = imageCatalogRepository.findAllPublicInAccount(user.getAccount(), user.getUserId()).isEmpty() ? getCloudbreakDefaultImageCatalog() : imageCatalogRepository.findOne(id);
    return imageCatalog;
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 15 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogService method getImageByCatalogName.

public StatedImage getImageByCatalogName(String imageId, String catalogName) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    StatedImage image;
    if (StringUtils.isEmpty(catalogName)) {
        image = getImage(imageId);
    } else {
        ImageCatalog imageCatalog = get(catalogName);
        if (imageCatalog != null) {
            image = getImage(imageCatalog.getImageCatalogUrl(), imageCatalog.getImageCatalogName(), imageId);
        } else {
            String msg = String.format("The specified image catalog '%s' could not be found.", catalogName);
            LOGGER.error(msg);
            throw new CloudbreakImageNotFoundException(msg);
        }
    }
    return image;
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Aggregations

ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)17 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)7 Test (org.junit.Test)4 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 UserProfile (com.sequenceiq.cloudbreak.domain.UserProfile)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Versioned (com.sequenceiq.cloudbreak.cloud.model.Versioned)1 CloudbreakImageCatalogV2 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2)1 CloudbreakVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)1 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)1 AuthenticatedUserService (com.sequenceiq.cloudbreak.controller.AuthenticatedUserService)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 ImageCatalogRepository (com.sequenceiq.cloudbreak.repository.ImageCatalogRepository)1 AuthorizationService (com.sequenceiq.cloudbreak.service.AuthorizationService)1 AccountPreferencesService (com.sequenceiq.cloudbreak.service.account.AccountPreferencesService)1 StatedImage.statedImage (com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage)1