Search in sources :

Example 6 with DeploymentException

use of org.craftercms.studio.api.v1.service.deployment.DeploymentException in project studio by craftercms.

the class BlobAwareContentRepositoryTest method publishRemoteFileTest.

@Test
public void publishRemoteFileTest() throws DeploymentException {
    DeploymentItemTO item = new DeploymentItemTO();
    item.setSite(SITE);
    item.setPath(ORIGINAL_PATH);
    List<DeploymentItemTO> items = singletonList(item);
    proxy.publish(SITE, EMPTY, items, ENV, USER, COMMENT);
    DeploymentItemTO pointerItem = new DeploymentItemTO();
    pointerItem.setSite(SITE);
    pointerItem.setPath(POINTER_PATH);
    verify(store).publish(eq(SITE), eq(EMPTY), itemsCaptor.capture(), eq(ENV), eq(USER), eq(COMMENT));
    assertEquals(itemsCaptor.getValue().get(0), item);
    verify(localV2).publish(eq(SITE), eq(EMPTY), itemsCaptor.capture(), eq(ENV), eq(USER), eq(COMMENT));
    assertEquals(itemsCaptor.getValue().get(0), pointerItem);
}
Also used : DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) Test(org.testng.annotations.Test)

Example 7 with DeploymentException

use of org.craftercms.studio.api.v1.service.deployment.DeploymentException in project studio by craftercms.

the class BlobAwareContentRepositoryTest method publishLocalFileTest.

@Test
public void publishLocalFileTest() throws DeploymentException {
    DeploymentItemTO item = new DeploymentItemTO();
    item.setSite(SITE);
    item.setPath(LOCAL_PATH);
    List<DeploymentItemTO> items = singletonList(item);
    proxy.publish(SITE, EMPTY, items, ENV, USER, COMMENT);
    DeploymentItemTO pointerItem = new DeploymentItemTO();
    pointerItem.setSite(SITE);
    pointerItem.setPath(LOCAL_PATH);
    verify(store, never()).publish(any(), any(), any(), any(), any(), any());
    verify(localV2).publish(eq(SITE), eq(EMPTY), itemsCaptor.capture(), eq(ENV), eq(USER), eq(COMMENT));
    assertEquals(itemsCaptor.getValue().get(0), pointerItem);
}
Also used : DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) Test(org.testng.annotations.Test)

Example 8 with DeploymentException

use of org.craftercms.studio.api.v1.service.deployment.DeploymentException in project studio by craftercms.

the class DmPublishServiceImpl method publish.

@Override
@ValidateParams
public void publish(@ValidateStringParam(name = "site") final String site, List<String> paths, ZonedDateTime launchDate, final MultiChannelPublishingContext mcpContext) {
    boolean scheduledDateIsNow = false;
    if (launchDate == null) {
        scheduledDateIsNow = true;
        launchDate = ZonedDateTime.now(ZoneOffset.UTC);
    }
    final String approver = securityService.getCurrentUser();
    final ZonedDateTime ld = launchDate;
    try {
        deploymentService.deploy(site, mcpContext.getPublishingChannelGroup(), paths, ld, approver, mcpContext.getSubmissionComment(), scheduledDateIsNow);
    } catch (DeploymentException e) {
        logger.error("Error while submitting paths to publish");
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) ValidateParams(org.craftercms.commons.validation.annotations.param.ValidateParams)

Example 9 with DeploymentException

use of org.craftercms.studio.api.v1.service.deployment.DeploymentException in project studio by craftercms.

the class PublishingManagerImpl method processMandatoryDependencies.

@Override
public List<DeploymentItemTO> processMandatoryDependencies(PublishRequest item, Set<String> pathsToDeploy, Set<String> missingDependenciesPaths) throws DeploymentException, ServiceLayerException {
    List<DeploymentItemTO> mandatoryDependencies = new ArrayList<DeploymentItemTO>();
    String site = item.getSite();
    String path = item.getPath();
    if (StringUtils.equals(item.getAction(), PublishRequest.Action.NEW) || StringUtils.equals(item.getAction(), PublishRequest.Action.MOVE)) {
        if (ContentUtils.matchesPatterns(path, servicesConfig.getPagePatterns(site))) {
            String helpPath = path.replace(FILE_SEPARATOR + getIndexFile(), "");
            int idx = helpPath.lastIndexOf(FILE_SEPARATOR);
            String parentPath = helpPath.substring(0, idx) + FILE_SEPARATOR + getIndexFile();
            if (objectStateService.isNew(site, parentPath) || objectMetadataManager.isRenamed(site, parentPath)) {
                if (!missingDependenciesPaths.contains(parentPath) && !pathsToDeploy.contains(parentPath)) {
                    deploymentService.cancelWorkflow(site, parentPath);
                    missingDependenciesPaths.add(parentPath);
                    PublishRequest parentItem = createMissingItem(site, parentPath, item);
                    DeploymentItemTO parentDeploymentItem = processItem(parentItem);
                    mandatoryDependencies.add(parentDeploymentItem);
                    mandatoryDependencies.addAll(processMandatoryDependencies(parentItem, pathsToDeploy, missingDependenciesPaths));
                }
            }
        }
        if (!isEnablePublishingWithoutDependencies()) {
            List<String> dependentPaths = dependencyService.getPublishingDependencies(site, path);
            for (String dependentPath : dependentPaths) {
                // TODO: SJ: This bypasses the Content Service, fix
                if (objectStateService.isNew(site, dependentPath) || objectMetadataManager.isRenamed(site, dependentPath)) {
                    if (!missingDependenciesPaths.contains(dependentPath) && !pathsToDeploy.contains(dependentPath)) {
                        deploymentService.cancelWorkflow(site, dependentPath);
                        missingDependenciesPaths.add(dependentPath);
                        PublishRequest dependentItem = createMissingItem(site, dependentPath, item);
                        DeploymentItemTO dependentDeploymentItem = processItem(dependentItem);
                        if (Objects.nonNull(dependentDeploymentItem)) {
                            mandatoryDependencies.add(dependentDeploymentItem);
                        }
                        mandatoryDependencies.addAll(processMandatoryDependencies(dependentItem, pathsToDeploy, missingDependenciesPaths));
                    }
                }
            }
        }
    }
    return mandatoryDependencies;
}
Also used : DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) ArrayList(java.util.ArrayList) PublishRequest(org.craftercms.studio.api.v1.dal.PublishRequest)

Example 10 with DeploymentException

use of org.craftercms.studio.api.v1.service.deployment.DeploymentException in project studio by craftercms.

the class WorkflowServiceImpl method _cancelWorkflow.

protected void _cancelWorkflow(String site, String path) throws ServiceLayerException {
    List<String> allItemsToCancel = getWorkflowAffectedPathsInternal(site, path);
    List<String> paths = new ArrayList<String>();
    for (String affectedItem : allItemsToCancel) {
        try {
            deploymentService.cancelWorkflow(site, affectedItem);
            ItemMetadata itemMetadata = objectMetadataManager.getProperties(site, affectedItem);
            if (itemMetadata != null) {
                itemMetadata.setSubmittedBy(StringUtils.EMPTY);
                itemMetadata.setSendEmail(0);
                itemMetadata.setSubmittedForDeletion(0);
                itemMetadata.setSubmissionComment(StringUtils.EMPTY);
                itemMetadata.setLaunchDate(null);
                itemMetadata.setSubmittedToEnvironment(StringUtils.EMPTY);
                objectMetadataManager.updateObjectMetadata(itemMetadata);
            }
            paths.add(affectedItem);
        } catch (DeploymentException e) {
            logger.error("Error occurred while trying to cancel workflow for path [" + affectedItem + "], site " + site, e);
        }
    }
    objectStateService.transitionBulk(site, paths, org.craftercms.studio.api.v1.service.objectstate.TransitionEvent.REJECT, State.NEW_UNPUBLISHED_UNLOCKED);
}
Also used : ArrayList(java.util.ArrayList) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata)

Aggregations

DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)12 DeploymentItemTO (org.craftercms.studio.api.v1.to.DeploymentItemTO)10 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)9 ArrayList (java.util.ArrayList)8 PublishRequest (org.craftercms.studio.api.v1.dal.PublishRequest)8 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)6 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)6 ZonedDateTime (java.time.ZonedDateTime)5 HashSet (java.util.HashSet)5 CryptoException (org.craftercms.commons.crypto.CryptoException)4 IOException (java.io.IOException)3 RetryingOperation (org.craftercms.studio.api.v2.annotation.RetryingOperation)3 Test (org.testng.annotations.Test)3 SimpleDateFormat (java.text.SimpleDateFormat)2 ItemMetadata (org.craftercms.studio.api.v1.dal.ItemMetadata)2 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)2 ContentNotFoundException (org.craftercms.studio.api.v1.exception.ContentNotFoundException)2 InvalidRemoteRepositoryCredentialsException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryCredentialsException)2 InvalidRemoteRepositoryException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryException)2 RemoteRepositoryNotFoundException (org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotFoundException)2