use of org.eclipse.che.api.workspace.server.devfile.exception.WorkspaceExportException in project che-server by eclipse-che.
the class CommandConverter method toDevfileCommand.
/**
* Converts the specified workspace command to devfile command.
*
* @param command source workspace command
* @return created devfile command based on the specified workspace command
* @throws WorkspaceExportException if workspace command does not has specified component name
* attribute where it should be run
*/
public CommandImpl toDevfileCommand(org.eclipse.che.api.workspace.server.model.impl.CommandImpl command) throws WorkspaceExportException {
String componentName = command.getAttributes().remove(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE);
if (componentName == null) {
throw new WorkspaceExportException(format("Command `%s` has no specified component where it should be run", command.getName()));
}
CommandImpl devCommand = new CommandImpl();
devCommand.setName(command.getName());
ActionImpl action = new ActionImpl();
action.setCommand(command.getCommandLine());
action.setType(command.getType());
action.setWorkdir(command.getAttributes().remove(WORKING_DIRECTORY_ATTRIBUTE));
action.setComponent(componentName);
action.setType(Constants.EXEC_ACTION_TYPE);
devCommand.getActions().add(action);
devCommand.setAttributes(command.getAttributes());
return devCommand;
}
use of org.eclipse.che.api.workspace.server.devfile.exception.WorkspaceExportException in project devspaces-images by redhat-developer.
the class CommandConverter method toDevfileCommand.
/**
* Converts the specified workspace command to devfile command.
*
* @param command source workspace command
* @return created devfile command based on the specified workspace command
* @throws WorkspaceExportException if workspace command does not has specified component name
* attribute where it should be run
*/
public CommandImpl toDevfileCommand(org.eclipse.che.api.workspace.server.model.impl.CommandImpl command) throws WorkspaceExportException {
String componentName = command.getAttributes().remove(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE);
if (componentName == null) {
throw new WorkspaceExportException(format("Command `%s` has no specified component where it should be run", command.getName()));
}
CommandImpl devCommand = new CommandImpl();
devCommand.setName(command.getName());
ActionImpl action = new ActionImpl();
action.setCommand(command.getCommandLine());
action.setType(command.getType());
action.setWorkdir(command.getAttributes().remove(WORKING_DIRECTORY_ATTRIBUTE));
action.setComponent(componentName);
action.setType(Constants.EXEC_ACTION_TYPE);
devCommand.getActions().add(action);
devCommand.setAttributes(command.getAttributes());
return devCommand;
}
Aggregations