Search in sources :

Example 11 with Recipe

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

the class RecipeController method createRecipe.

private RecipeResponse createRecipe(IdentityUser user, RecipeRequest recipeRequest, boolean publicInAccount) {
    Recipe recipe = conversionService.convert(recipeRequest, Recipe.class);
    recipe.setPublicInAccount(publicInAccount);
    recipe = recipeService.create(user, recipe);
    notify(user, ResourceEvent.RECIPE_CREATED);
    return conversionService.convert(recipe, RecipeResponse.class);
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe)

Example 12 with Recipe

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

the class RecipeController method getPrivates.

@Override
public Set<RecipeResponse> getPrivates() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<Recipe> recipes = recipeService.retrievePrivateRecipes(user);
    return toJsonSet(recipes);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Recipe(com.sequenceiq.cloudbreak.domain.Recipe)

Example 13 with Recipe

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

the class RecipeController method getPublic.

@Override
public RecipeResponse getPublic(String name) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Recipe recipe = recipeService.getPublicRecipe(name, user);
    return conversionService.convert(recipe, RecipeResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Recipe(com.sequenceiq.cloudbreak.domain.Recipe)

Example 14 with Recipe

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

the class RecipeController method getPrivate.

@Override
public RecipeResponse getPrivate(String name) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Recipe recipe = recipeService.getPrivateRecipe(name, user);
    return conversionService.convert(recipe, RecipeResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Recipe(com.sequenceiq.cloudbreak.domain.Recipe)

Example 15 with Recipe

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

the class RecipeRequestToRecipeConverter method convert.

@Override
public Recipe convert(RecipeRequest json) {
    Recipe recipe = new Recipe();
    if (!Strings.isNullOrEmpty(json.getName())) {
        recipe.setName(json.getName());
    } else {
        String name = missingResourceNameGenerator.generateName(APIResourceType.RECIPE);
        if (json.getUri() != null) {
            String[] splitUrl = json.getUri().split("/");
            String lastPart = splitUrl[splitUrl.length - 1];
            String[] lastPartQueryArray = lastPart.split("\\?");
            name += lastPartQueryArray[0];
        }
        recipe.setName(name);
    }
    recipe.setDescription(json.getDescription());
    recipe.setRecipeType(json.getRecipeType());
    recipe.setContent(json.getContent());
    recipe.setUri(json.getUri());
    if (recipe.getUri() != null && recipe.getContent() == null) {
        recipe.setContent(fetchScriptContent(recipe.getUri()));
    }
    return recipe;
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe)

Aggregations

Recipe (com.sequenceiq.cloudbreak.domain.Recipe)20 RecipeScript (com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript)5 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)5 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)5 IOException (java.io.IOException)3 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 ArrayList (java.util.ArrayList)2 FileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)1 RecipeRequest (com.sequenceiq.cloudbreak.api.model.RecipeRequest)1 FileSystemConfigurator (com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)1 RecipeModel (com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1