Search in sources :

Example 1 with EnvironmentNotFoundException

use of org.craftercms.studio.api.v1.exception.EnvironmentNotFoundException in project studio by craftercms.

the class DeploymentServiceImpl method publishCommits.

@Override
@ValidateParams
public void publishCommits(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "environment") String environment, List<String> commitIds, @ValidateStringParam(name = "comment") String comment) throws SiteNotFoundException, EnvironmentNotFoundException, CommitNotFoundException {
    if (!siteService.exists(site)) {
        throw new SiteNotFoundException();
    }
    Set<String> environments = getAllPublishedEnvironments(site);
    if (!environments.contains(environment)) {
        throw new EnvironmentNotFoundException();
    }
    if (!checkCommitIds(site, commitIds)) {
        throw new CommitNotFoundException();
    }
    logger.debug("Creating publish request items for queue for site " + site + " environment " + environment);
    List<PublishRequest> publishRequests = createCommitItems(site, environment, commitIds, ZonedDateTime.now(ZoneOffset.UTC), securityService.getCurrentUser(), comment);
    logger.debug("Insert publish request items to the queue");
    for (PublishRequest request : publishRequests) {
        publishRequestMapper.insertItemForDeployment(request);
    }
    logger.debug("Completed adding commits to publishing queue");
}
Also used : EnvironmentNotFoundException(org.craftercms.studio.api.v1.exception.EnvironmentNotFoundException) CommitNotFoundException(org.craftercms.studio.api.v1.exception.CommitNotFoundException) PublishRequest(org.craftercms.studio.api.v1.dal.PublishRequest) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) ValidateParams(org.craftercms.commons.validation.annotations.param.ValidateParams)

Aggregations

ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)1 PublishRequest (org.craftercms.studio.api.v1.dal.PublishRequest)1 CommitNotFoundException (org.craftercms.studio.api.v1.exception.CommitNotFoundException)1 EnvironmentNotFoundException (org.craftercms.studio.api.v1.exception.EnvironmentNotFoundException)1 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)1