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);
}
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);
}
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");
}
}
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;
}
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);
}
Aggregations