Search in sources :

Example 1 with DevfileCreatedEvent

use of org.eclipse.che.api.devfile.shared.event.DevfileCreatedEvent in project che-server by eclipse-che.

the class UserDevfileManager method createDevfile.

/**
 * Stores {@link Devfile} instance
 *
 * @param userDevfile instance of user devfile which would be stored
 * @return new persisted devfile instance
 * @throws ConflictException when any conflict occurs (e.g Devfile with such name already exists
 *     for {@code owner})
 * @throws NullPointerException when {@code devfile} is null
 * @throws ServerException when any other error occurs
 */
public UserDevfile createDevfile(UserDevfile userDevfile) throws ServerException, NotFoundException, ConflictException {
    requireNonNull(userDevfile, "Required non-null userdevfile");
    requireNonNull(userDevfile.getDevfile(), "Required non-null devfile");
    String name = userDevfile.getName() != null ? userDevfile.getName() : NameGenerator.generate("devfile-", 5);
    UserDevfile result = userDevfileDao.create(new UserDevfileImpl(NameGenerator.generate("id-", 16), accountManager.getByName(EnvironmentContext.getCurrent().getSubject().getUserName()), name, userDevfile.getDescription(), userDevfile.getDevfile()));
    LOG.debug("UserDevfile '{}' with id '{}' created by user '{}'", result.getName(), result.getId(), EnvironmentContext.getCurrent().getSubject().getUserName());
    eventService.publish(new DevfileCreatedEvent(result));
    return result;
}
Also used : UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileCreatedEvent(org.eclipse.che.api.devfile.shared.event.DevfileCreatedEvent)

Example 2 with DevfileCreatedEvent

use of org.eclipse.che.api.devfile.shared.event.DevfileCreatedEvent in project devspaces-images by redhat-developer.

the class UserDevfileManager method createDevfile.

/**
 * Stores {@link Devfile} instance
 *
 * @param userDevfile instance of user devfile which would be stored
 * @return new persisted devfile instance
 * @throws ConflictException when any conflict occurs (e.g Devfile with such name already exists
 *     for {@code owner})
 * @throws NullPointerException when {@code devfile} is null
 * @throws ServerException when any other error occurs
 */
public UserDevfile createDevfile(UserDevfile userDevfile) throws ServerException, NotFoundException, ConflictException {
    requireNonNull(userDevfile, "Required non-null userdevfile");
    requireNonNull(userDevfile.getDevfile(), "Required non-null devfile");
    String name = userDevfile.getName() != null ? userDevfile.getName() : NameGenerator.generate("devfile-", 5);
    UserDevfile result = userDevfileDao.create(new UserDevfileImpl(NameGenerator.generate("id-", 16), accountManager.getByName(EnvironmentContext.getCurrent().getSubject().getUserName()), name, userDevfile.getDescription(), userDevfile.getDevfile()));
    LOG.debug("UserDevfile '{}' with id '{}' created by user '{}'", result.getName(), result.getId(), EnvironmentContext.getCurrent().getSubject().getUserName());
    eventService.publish(new DevfileCreatedEvent(result));
    return result;
}
Also used : UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileCreatedEvent(org.eclipse.che.api.devfile.shared.event.DevfileCreatedEvent)

Aggregations

UserDevfile (org.eclipse.che.api.core.model.workspace.devfile.UserDevfile)2 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)2 DevfileCreatedEvent (org.eclipse.che.api.devfile.shared.event.DevfileCreatedEvent)2