Search in sources :

Example 1 with DevfileUpdatedEvent

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

the class UserDevfileManager method updateUserDevfile.

/**
 * Updates an existing user devfile in accordance to the new configuration.
 *
 * <p>Note: Replace strategy is used for user devfile update, it means that existing devfile data
 * will be replaced with given {@code update}.
 *
 * @param update user devfile update
 * @return updated user devfile
 * @throws NullPointerException when {@code update} is null
 * @throws ConflictException when any conflict occurs.
 * @throws NotFoundException when user devfile with given id not found
 * @throws ServerException when any server error occurs
 */
public UserDevfile updateUserDevfile(UserDevfile update) throws ConflictException, NotFoundException, ServerException {
    requireNonNull(update);
    Optional<UserDevfile> result = userDevfileDao.update(update);
    UserDevfile devfile = result.orElseThrow(() -> new NotFoundException(format("Devfile with id '%s' doesn't exist", update.getId())));
    LOG.debug("UserDevfile '{}' with id '{}' update by user '{}'", devfile.getName(), devfile.getId(), EnvironmentContext.getCurrent().getSubject().getUserName());
    eventService.publish(new DevfileUpdatedEvent(devfile));
    return devfile;
}
Also used : UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) NotFoundException(org.eclipse.che.api.core.NotFoundException) DevfileUpdatedEvent(org.eclipse.che.api.devfile.shared.event.DevfileUpdatedEvent)

Example 2 with DevfileUpdatedEvent

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

the class UserDevfileManager method updateUserDevfile.

/**
 * Updates an existing user devfile in accordance to the new configuration.
 *
 * <p>Note: Replace strategy is used for user devfile update, it means that existing devfile data
 * will be replaced with given {@code update}.
 *
 * @param update user devfile update
 * @return updated user devfile
 * @throws NullPointerException when {@code update} is null
 * @throws ConflictException when any conflict occurs.
 * @throws NotFoundException when user devfile with given id not found
 * @throws ServerException when any server error occurs
 */
public UserDevfile updateUserDevfile(UserDevfile update) throws ConflictException, NotFoundException, ServerException {
    requireNonNull(update);
    Optional<UserDevfile> result = userDevfileDao.update(update);
    UserDevfile devfile = result.orElseThrow(() -> new NotFoundException(format("Devfile with id '%s' doesn't exist", update.getId())));
    LOG.debug("UserDevfile '{}' with id '{}' update by user '{}'", devfile.getName(), devfile.getId(), EnvironmentContext.getCurrent().getSubject().getUserName());
    eventService.publish(new DevfileUpdatedEvent(devfile));
    return devfile;
}
Also used : UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) NotFoundException(org.eclipse.che.api.core.NotFoundException) DevfileUpdatedEvent(org.eclipse.che.api.devfile.shared.event.DevfileUpdatedEvent)

Aggregations

NotFoundException (org.eclipse.che.api.core.NotFoundException)2 UserDevfile (org.eclipse.che.api.core.model.workspace.devfile.UserDevfile)2 DevfileUpdatedEvent (org.eclipse.che.api.devfile.shared.event.DevfileUpdatedEvent)2