Search in sources :

Example 1 with EventListener

use of org.craftercms.studio.api.v1.ebus.EventListener in project studio by craftercms.

the class EnvironmentDeployer method onEnvironmentDeploymentEvent.

@EventListener(EVENT_PUBLISH_TO_ENVIRONMENT)
public void onEnvironmentDeploymentEvent(DeploymentEventContext context) {
    List<DeploymentItem> items = context.getItems();
    List<DeploymentItemTO> deploymentItems = new ArrayList<DeploymentItemTO>();
    for (DeploymentItem item : items) {
        DeploymentItemTO deploymentItem = new DeploymentItemTO();
        deploymentItem.setSite(item.getSite());
        deploymentItem.setPath(item.getPath());
        deploymentItem.setCommitId(item.getCommitId());
        deploymentItem.setPackageId(item.getPackageId());
    }
    try {
        contentRepository.publish(context.getSite(), StringUtils.EMPTY, deploymentItems, context.getEnvironment(), context.getAuthor(), context.getComment());
    } catch (DeploymentException e) {
        logger.error("Error when publishing site " + context.getSite() + " to environment " + context.getEnvironment(), e);
    }
}
Also used : DeploymentItem(org.craftercms.studio.api.v1.ebus.DeploymentItem) DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) ArrayList(java.util.ArrayList) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) EventListener(org.craftercms.studio.api.v1.ebus.EventListener)

Aggregations

ArrayList (java.util.ArrayList)1 DeploymentItem (org.craftercms.studio.api.v1.ebus.DeploymentItem)1 EventListener (org.craftercms.studio.api.v1.ebus.EventListener)1 DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)1 DeploymentItemTO (org.craftercms.studio.api.v1.to.DeploymentItemTO)1