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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations