use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class CreateWorkspaceViewImpl method addRecipesToPanel.
private void addRecipesToPanel(List<RecipeDescriptor> recipes) {
tagsPanel.clear();
for (RecipeDescriptor descriptor : recipes) {
RecipeWidget tag = tagFactory.create(descriptor);
tag.setDelegate(this);
tagsPanel.add(tag);
}
popupPanel.setWidget(tagsPanel);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class GdbConfigurationPagePresenter method setHosts.
private void setHosts(List<Machine> machines) {
List<Promise<RecipeDescriptor>> recipePromises = new ArrayList<>(machines.size());
for (Machine machine : machines) {
String location = machine.getConfig().getSource().getLocation();
String recipeId = getRecipeId(location);
recipePromises.add(recipeServiceClient.getRecipe(recipeId));
}
@SuppressWarnings("unchecked") final Promise<RecipeDescriptor>[] recipePromisesArray = (Promise<RecipeDescriptor>[]) recipePromises.toArray();
setHostsList(recipePromisesArray, machines);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class RecipeServiceTest method shouldCreateNewRecipe.
@Test
public void shouldCreateNewRecipe() throws Exception {
final NewRecipe newRecipe = newDto(NewRecipe.class).withType("docker").withName("name").withScript("FROM ubuntu\n").withTags(asList("java", "mongo"));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(newRecipe).when().post(SECURE_PATH + "/recipe");
assertEquals(response.getStatusCode(), 201);
verify(recipeDao).create(any(RecipeImpl.class));
final RecipeDescriptor descriptor = unwrapDto(response, RecipeDescriptor.class);
assertNotNull(descriptor.getId());
assertEquals(descriptor.getName(), newRecipe.getName());
assertEquals(descriptor.getCreator(), USER_ID);
assertEquals(descriptor.getScript(), newRecipe.getScript());
assertEquals(descriptor.getTags(), newRecipe.getTags());
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class TargetsPresenter method updateTargets.
/**
* Fetches all recipes from the server, makes a list of targets and selects specified target.
*/
@Override
public void updateTargets(final String preselectTargetName) {
targets.clear();
machines.clear();
getMachines(appContext.getWorkspaceId()).then(new Operation<List<MachineEntity>>() {
@Override
public void apply(List<MachineEntity> machineList) throws OperationException {
//create Target objects from all machines
for (MachineEntity machine : machineList) {
final MachineConfig machineConfig = machine.getConfig();
machines.put(machineConfig.getName(), machine);
final String targetCategory = machineConfig.isDev() ? machineLocale.devMachineCategory() : machineConfig.getType();
final Target target = createTarget(machineConfig.getName(), targetCategory);
target.setConnected(isMachineRunning(machine));
targets.put(target.getName(), target);
}
//create Target objects from recipe with ssh type
recipeServiceClient.getAllRecipes().then(new Operation<List<RecipeDescriptor>>() {
@Override
public void apply(List<RecipeDescriptor> recipeList) throws OperationException {
for (RecipeDescriptor recipe : recipeList) {
//only for SSH recipes
if (!machineLocale.targetsViewCategorySsh().equalsIgnoreCase(recipe.getType())) {
continue;
}
Target target = targets.get(recipe.getName());
if (target == null) {
target = createTarget(recipe.getName(), recipe.getType());
}
target.setRecipe(recipe);
categoryPageRegistry.getCategoryPage(target.getCategory()).getTargetManager().restoreTarget(target);
targets.put(target.getName(), target);
}
view.showTargets(new ArrayList<>(targets.values()));
selectTarget(preselectTargetName == null ? selectedTarget : targets.get(preselectTargetName));
}
});
}
});
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class SshViewImpl method restoreTargetFields.
@Override
public boolean restoreTargetFields(SshMachineTarget target) {
if (target == null) {
return false;
}
final RecipeDescriptor targetRecipe = target.getRecipe();
if (targetRecipe == null) {
return false;
}
try {
final JSONObject json = JSONParser.parseStrict(targetRecipe.getScript()).isObject();
String name = targetRecipe.getName();
target.setName(name);
if (json.get("host") != null) {
String host = json.get("host").isString().stringValue();
target.setHost(host);
}
if (json.get("port") != null) {
String port = json.get("port").isString().stringValue();
target.setPort(port);
}
if (json.get("username") != null) {
String username = json.get("username").isString().stringValue();
target.setUserName(username);
}
if (json.get("password") != null) {
String password = json.get("password").isString().stringValue();
target.setPassword(password);
}
target.setDirty(false);
} catch (Exception e) {
Log.error(this.getClass(), "Unable to parse recipe JSON. " + e.getMessage());
return false;
}
return true;
}
Aggregations