Search in sources :

Example 1 with MultiChannelPublishingContext

use of org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext in project studio by craftercms.

the class WorkflowServiceImpl method approveWithoutDependencies.

/**
 * approve workflows and schedule them as specified in the request
 *
 * @param site
 * @param request
 * @return call result
 * @throws ServiceLayerException
 */
@SuppressWarnings("unchecked")
protected ResultTO approveWithoutDependencies(String site, String request, Operation operation) {
    String approver = securityService.getCurrentUser();
    ResultTO result = new ResultTO();
    try {
        JSONObject requestObject = JSONObject.fromObject(request);
        JSONArray items = requestObject.getJSONArray(JSON_KEY_ITEMS);
        String scheduledDate = null;
        if (requestObject.containsKey(JSON_KEY_SCHEDULED_DATE)) {
            scheduledDate = requestObject.getString(JSON_KEY_SCHEDULED_DATE);
        }
        boolean isNow = (requestObject.containsKey(JSON_KEY_IS_NOW)) ? requestObject.getBoolean(JSON_KEY_IS_NOW) : false;
        String publishChannelGroupName = (requestObject.containsKey(JSON_KEY_PUBLISH_CHANNEL)) ? requestObject.getString(JSON_KEY_PUBLISH_CHANNEL) : null;
        JSONObject jsonObjectStatus = requestObject.getJSONObject(JSON_KEY_STATUS_SET);
        String statusMessage = (jsonObjectStatus != null && jsonObjectStatus.containsKey(JSON_KEY_STATUS_MESSAGE)) ? jsonObjectStatus.getString(JSON_KEY_STATUS_MESSAGE) : null;
        String submissionComment = (requestObject != null && requestObject.containsKey(JSON_KEY_SUBMISSION_COMMENT)) ? requestObject.getString(JSON_KEY_SUBMISSION_COMMENT) : "Test Go Live";
        MultiChannelPublishingContext mcpContext = new MultiChannelPublishingContext(publishChannelGroupName, statusMessage, submissionComment);
        int length = items.size();
        if (length == 0) {
            throw new ServiceLayerException("No items provided to go live.");
        }
        List<String> submittedPaths = new ArrayList<String>();
        String responseMessageKey = null;
        SimpleDateFormat format = new SimpleDateFormat(StudioConstants.DATE_PATTERN_WORKFLOW_WITH_TZ);
        List<DmDependencyTO> submittedItems = new ArrayList<>();
        for (int index = 0; index < length; index++) {
            String stringItem = items.optString(index);
            submittedPaths.add(stringItem);
            DmDependencyTO submittedItem = null;
            submittedItem = getSubmittedItemApproveWithoutDependencies(site, stringItem, format, scheduledDate);
            List<DmDependencyTO> submitForDeleteChildren = removeSubmitToDeleteChildrenForGoLive(submittedItem, operation);
            if (submittedItem.isReference()) {
                submittedItem.setReference(false);
            }
            submittedItems.add(submittedItem);
            submittedItems.addAll(submitForDeleteChildren);
        }
        switch(operation) {
            case GO_LIVE:
                if (scheduledDate != null && isNow == false) {
                    responseMessageKey = NotificationService.COMPLETE_SCHEDULE_GO_LIVE;
                } else {
                    responseMessageKey = NotificationService.COMPLETE_GO_LIVE;
                }
                List<DmDependencyTO> submitToDeleteItems = new ArrayList<>();
                List<DmDependencyTO> goLiveItems = new ArrayList<>();
                List<DmDependencyTO> renameItems = new ArrayList<>();
                for (DmDependencyTO item : submittedItems) {
                    if (item.isSubmittedForDeletion()) {
                        submitToDeleteItems.add(item);
                    } else {
                        if (!isItemRenamed(site, item)) {
                            goLiveItems.add(item);
                        } else {
                            renameItems.add(item);
                        }
                    }
                }
                if (!submitToDeleteItems.isEmpty()) {
                    doDelete(site, submitToDeleteItems, approver);
                }
                if (!goLiveItems.isEmpty()) {
                    List<String> goLivePaths = new ArrayList<>();
                    Set<String> processedPaths = new HashSet<String>();
                    for (DmDependencyTO goLiveItem : goLiveItems) {
                        resolveSubmittedPaths(site, goLiveItem, goLivePaths, processedPaths);
                    }
                    goLive(site, goLiveItems, approver, mcpContext);
                }
                if (!renameItems.isEmpty()) {
                    List<String> renamePaths = new ArrayList<>();
                    List<DmDependencyTO> renamedChildren = new ArrayList<>();
                    for (DmDependencyTO renameItem : renameItems) {
                        renamedChildren.addAll(getChildrenForRenamedItem(site, renameItem));
                        renamePaths.add(renameItem.getUri());
                        objectStateService.setSystemProcessing(site, renameItem.getUri(), true);
                    }
                    for (DmDependencyTO renamedChild : renamedChildren) {
                        renamePaths.add(renamedChild.getUri());
                        objectStateService.setSystemProcessing(site, renamedChild.getUri(), true);
                    }
                    renameItems.addAll(renamedChildren);
                    // Set proper information of all renameItems before send them to GoLive
                    for (int i = 0; i < renameItems.size(); i++) {
                        DmDependencyTO renamedItem = renameItems.get(i);
                        if (renamedItem.getScheduledDate() != null && renamedItem.getScheduledDate().isAfter(ZonedDateTime.now(ZoneOffset.UTC))) {
                            renamedItem.setNow(false);
                        } else {
                            renamedItem.setNow(true);
                        }
                        renameItems.set(i, renamedItem);
                    }
                    goLive(site, renameItems, approver, mcpContext);
                }
                break;
            case DELETE:
                responseMessageKey = NotificationService.COMPLETE_DELETE;
                List<String> deletePaths = new ArrayList<>();
                List<String> nodeRefs = new ArrayList<String>();
                for (DmDependencyTO deletedItem : submittedItems) {
                    deletePaths.add(deletedItem.getUri());
                    ContentItemTO contentItem = contentService.getContentItem(site, deletedItem.getUri());
                    if (contentItem != null) {
                    // nodeRefs.add(nodeRef.getId());
                    }
                }
                doDelete(site, submittedItems, approver);
        }
        result.setSuccess(true);
        result.setStatus(200);
        result.setMessage(notificationService.getNotificationMessage(site, NotificationMessageType.CompleteMessages, responseMessageKey, Locale.ENGLISH));
    } catch (JSONException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    } catch (ServiceLayerException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    }
    return result;
}
Also used : JSONArray(net.sf.json.JSONArray) ArrayList(java.util.ArrayList) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) JSONException(net.sf.json.JSONException) DmDependencyTO(org.craftercms.studio.api.v1.to.DmDependencyTO) ResultTO(org.craftercms.studio.api.v1.to.ResultTO) ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) MultiChannelPublishingContext(org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext) JSONObject(net.sf.json.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet)

Example 2 with MultiChannelPublishingContext

use of org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext in project studio by craftercms.

the class WorkflowServiceImpl method approve_new.

/**
 * approve workflows and schedule them as specified in the request
 *
 * @param site
 * @param request
 * @return call result
 * @throws ServiceLayerException
 */
@SuppressWarnings("unchecked")
protected ResultTO approve_new(String site, String request, Operation operation) {
    String approver = securityService.getCurrentUser();
    ResultTO result = new ResultTO();
    try {
        JSONObject requestObject = JSONObject.fromObject(request);
        JSONArray items = requestObject.getJSONArray(JSON_KEY_ITEMS);
        String scheduledDate = null;
        if (requestObject.containsKey(JSON_KEY_SCHEDULED_DATE)) {
            scheduledDate = requestObject.getString(JSON_KEY_SCHEDULED_DATE);
        }
        boolean isNow = (requestObject.containsKey(JSON_KEY_IS_NOW)) ? requestObject.getBoolean(JSON_KEY_IS_NOW) : false;
        String publishChannelGroupName = (requestObject.containsKey(JSON_KEY_PUBLISH_CHANNEL)) ? requestObject.getString(JSON_KEY_PUBLISH_CHANNEL) : null;
        JSONObject jsonObjectStatus = requestObject.getJSONObject(JSON_KEY_STATUS_SET);
        String statusMessage = (jsonObjectStatus != null && jsonObjectStatus.containsKey(JSON_KEY_STATUS_MESSAGE)) ? jsonObjectStatus.getString(JSON_KEY_STATUS_MESSAGE) : null;
        String submissionComment = (requestObject != null && requestObject.containsKey(JSON_KEY_SUBMISSION_COMMENT)) ? requestObject.getString(JSON_KEY_SUBMISSION_COMMENT) : "Test Go Live";
        MultiChannelPublishingContext mcpContext = new MultiChannelPublishingContext(publishChannelGroupName, statusMessage, submissionComment);
        int length = items.size();
        if (length == 0) {
            throw new ServiceLayerException("No items provided to go live.");
        }
        List<String> submittedPaths = new ArrayList<String>();
        String responseMessageKey = null;
        SimpleDateFormat format = new SimpleDateFormat(StudioConstants.DATE_PATTERN_WORKFLOW_WITH_TZ);
        List<DmDependencyTO> submittedItems = new ArrayList<>();
        for (int index = 0; index < length; index++) {
            String stringItem = items.optString(index);
            submittedPaths.add(stringItem);
            DmDependencyTO submittedItem = null;
            submittedItem = getSubmittedItem_new(site, stringItem, format, scheduledDate);
            List<DmDependencyTO> submitForDeleteChildren = removeSubmitToDeleteChildrenForGoLive(submittedItem, operation);
            if (submittedItem.isReference()) {
                submittedItem.setReference(false);
            }
            submittedItems.add(submittedItem);
            submittedItems.addAll(submitForDeleteChildren);
        }
        switch(operation) {
            case GO_LIVE:
                if (scheduledDate != null && !isNow) {
                    responseMessageKey = NotificationService.COMPLETE_SCHEDULE_GO_LIVE;
                } else {
                    responseMessageKey = NotificationService.COMPLETE_GO_LIVE;
                }
                List<DmDependencyTO> submitToDeleteItems = new ArrayList<>();
                List<DmDependencyTO> goLiveItems = new ArrayList<>();
                List<DmDependencyTO> renameItems = new ArrayList<>();
                for (DmDependencyTO item : submittedItems) {
                    if (item.isSubmittedForDeletion()) {
                        submitToDeleteItems.add(item);
                    } else {
                        if (!isItemRenamed(site, item)) {
                            goLiveItems.add(item);
                        } else {
                            renameItems.add(item);
                        }
                    }
                }
                if (!submitToDeleteItems.isEmpty()) {
                    doDelete(site, submitToDeleteItems, approver);
                }
                if (!goLiveItems.isEmpty()) {
                    List<DmDependencyTO> references = getRefAndChildOfDiffDateFromParent_new(site, goLiveItems, true);
                    List<DmDependencyTO> children = getRefAndChildOfDiffDateFromParent_new(site, goLiveItems, false);
                    goLiveItems.addAll(references);
                    goLiveItems.addAll(children);
                    List<DmDependencyTO> dependencies = addDependenciesForSubmittedItems(site, submittedItems, format, scheduledDate);
                    goLiveItems.addAll(dependencies);
                    List<String> goLivePaths = new ArrayList<>();
                    List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
                    for (DmDependencyTO goLiveItem : goLiveItems) {
                        goLivePaths.add(goLiveItem.getUri());
                        AuditLogParameter auditLogParameter = new AuditLogParameter();
                        auditLogParameter.setTargetId(site + ":" + goLiveItem.getUri());
                        auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
                        auditLogParameter.setTargetValue(goLiveItem.getUri());
                        auditLogParameters.add(auditLogParameter);
                    }
                    goLive(site, goLiveItems, approver, mcpContext);
                    SiteFeed siteFeed = siteService.getSite(site);
                    AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
                    auditLog.setActorId(approver);
                    auditLog.setSiteId(siteFeed.getId());
                    auditLog.setPrimaryTargetId(site);
                    auditLog.setPrimaryTargetType(TARGET_TYPE_SITE);
                    auditLog.setPrimaryTargetValue(site);
                    auditLog.setParameters(auditLogParameters);
                    if (scheduledDate != null && !isNow) {
                        auditLog.setOperation(OPERATION_APPROVE_SCHEDULED);
                    } else {
                        auditLog.setOperation(OPERATION_APPROVE);
                    }
                    auditServiceInternal.insertAuditLog(auditLog);
                }
                if (!renameItems.isEmpty()) {
                    List<String> renamePaths = new ArrayList<>();
                    List<DmDependencyTO> renamedChildren = new ArrayList<>();
                    for (DmDependencyTO renameItem : renameItems) {
                        renamedChildren.addAll(getChildrenForRenamedItem(site, renameItem));
                        renamePaths.add(renameItem.getUri());
                        objectStateService.setSystemProcessing(site, renameItem.getUri(), true);
                    }
                    for (DmDependencyTO renamedChild : renamedChildren) {
                        renamePaths.add(renamedChild.getUri());
                        objectStateService.setSystemProcessing(site, renamedChild.getUri(), true);
                    }
                    renameItems.addAll(renamedChildren);
                    // Set proper information of all renameItems before send them to GoLive
                    for (int i = 0; i < renameItems.size(); i++) {
                        DmDependencyTO renamedItem = renameItems.get(i);
                        if (renamedItem.getScheduledDate() != null && renamedItem.getScheduledDate().isAfter(ZonedDateTime.now(ZoneOffset.UTC))) {
                            renamedItem.setNow(false);
                        } else {
                            renamedItem.setNow(true);
                        }
                        renameItems.set(i, renamedItem);
                    }
                    goLive(site, renameItems, approver, mcpContext);
                }
                break;
            case DELETE:
                responseMessageKey = NotificationService.COMPLETE_DELETE;
                List<String> deletePaths = new ArrayList<>();
                List<String> nodeRefs = new ArrayList<String>();
                List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
                for (DmDependencyTO deletedItem : submittedItems) {
                    // deletedItem.setScheduledDate(getScheduledDate(site, format, scheduledDate));
                    deletePaths.add(deletedItem.getUri());
                    AuditLogParameter auditLogParameter = new AuditLogParameter();
                    auditLogParameter.setTargetId(site + ":" + deletedItem.getUri());
                    auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
                    auditLogParameter.setTargetValue(deletedItem.getUri());
                    auditLogParameters.add(auditLogParameter);
                }
                doDelete(site, submittedItems, approver);
                SiteFeed siteFeed = siteService.getSite(site);
                AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
                auditLog.setOperation(OPERATION_APPROVE);
                auditLog.setActorId(approver);
                auditLog.setSiteId(siteFeed.getId());
                auditLog.setPrimaryTargetId(site);
                auditLog.setPrimaryTargetType(TARGET_TYPE_SITE);
                auditLog.setPrimaryTargetValue(site);
                auditLog.setParameters(auditLogParameters);
                auditServiceInternal.insertAuditLog(auditLog);
        }
        result.setSuccess(true);
        result.setStatus(200);
        result.setMessage(notificationService.getNotificationMessage(site, NotificationMessageType.CompleteMessages, responseMessageKey, Locale.ENGLISH));
    } catch (JSONException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    } catch (ServiceLayerException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    }
    return result;
}
Also used : JSONArray(net.sf.json.JSONArray) ArrayList(java.util.ArrayList) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) JSONException(net.sf.json.JSONException) DmDependencyTO(org.craftercms.studio.api.v1.to.DmDependencyTO) ResultTO(org.craftercms.studio.api.v1.to.ResultTO) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog) MultiChannelPublishingContext(org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext) JSONObject(net.sf.json.JSONObject) SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) AuditLogParameter(org.craftercms.studio.api.v2.dal.AuditLogParameter) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with MultiChannelPublishingContext

use of org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext in project studio by craftercms.

the class ImportServiceImpl method submitToGoLive.

/**
 * submit imported items to go live
 *
 * @param site
 * @param publishChannelGroup
 * @param importedFullPaths
 */
protected void submitToGoLive(String site, String publishChannelGroup, List<String> importedFullPaths) {
    MultiChannelPublishingContext mcpContext = new MultiChannelPublishingContext(publishChannelGroup, "", "Import Service");
    dmPublishService.publish(site, importedFullPaths, null, mcpContext);
    logger.info("All files have been submitted to be publish");
}
Also used : MultiChannelPublishingContext(org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext)

Example 4 with MultiChannelPublishingContext

use of org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext 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 5 with MultiChannelPublishingContext

use of org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext in project studio by craftercms.

the class WorkflowServiceImpl method approve.

/**
 * approve workflows and schedule them as specified in the request
 *
 * @param site
 * @param request
 * @return call result
 * @throws ServiceLayerException
 */
@SuppressWarnings("unchecked")
protected ResultTO approve(String site, String request, Operation operation) {
    String approver = securityService.getCurrentUser();
    ResultTO result = new ResultTO();
    try {
        JSONObject requestObject = JSONObject.fromObject(request);
        JSONArray items = requestObject.getJSONArray(JSON_KEY_ITEMS);
        String scheduledDate = null;
        if (requestObject.containsKey(JSON_KEY_SCHEDULED_DATE)) {
            scheduledDate = requestObject.getString(JSON_KEY_SCHEDULED_DATE);
        }
        boolean isNow = (requestObject.containsKey(JSON_KEY_IS_NOW)) ? requestObject.getBoolean(JSON_KEY_IS_NOW) : false;
        String publishChannelGroupName = (requestObject.containsKey(JSON_KEY_PUBLISH_CHANNEL)) ? requestObject.getString(JSON_KEY_PUBLISH_CHANNEL) : null;
        JSONObject jsonObjectStatus = requestObject.getJSONObject(JSON_KEY_STATUS_SET);
        String statusMessage = (jsonObjectStatus != null && jsonObjectStatus.containsKey(JSON_KEY_STATUS_MESSAGE)) ? jsonObjectStatus.getString(JSON_KEY_STATUS_MESSAGE) : null;
        String submissionComment = (requestObject != null && requestObject.containsKey(JSON_KEY_SUBMISSION_COMMENT)) ? requestObject.getString(JSON_KEY_SUBMISSION_COMMENT) : "Test Go Live";
        MultiChannelPublishingContext mcpContext = new MultiChannelPublishingContext(publishChannelGroupName, statusMessage, submissionComment);
        int length = items.size();
        if (length == 0) {
            throw new ServiceLayerException("No items provided to go live.");
        }
        String responseMessageKey = null;
        SimpleDateFormat format = new SimpleDateFormat(StudioConstants.DATE_PATTERN_WORKFLOW_WITH_TZ);
        List<DmDependencyTO> submittedItems = new ArrayList<>();
        for (int index = 0; index < length; index++) {
            String stringItem = items.optString(index);
            DmDependencyTO submittedItem = null;
            submittedItem = getSubmittedItem(site, stringItem, format, scheduledDate, null);
            List<DmDependencyTO> submitForDeleteChildren = removeSubmitToDeleteChildrenForGoLive(submittedItem, operation);
            if (submittedItem.isReference()) {
                submittedItem.setReference(false);
            }
            submittedItems.add(submittedItem);
            submittedItems.addAll(submitForDeleteChildren);
        }
        switch(operation) {
            case GO_LIVE:
                if (scheduledDate != null && isNow == false) {
                    responseMessageKey = NotificationService.COMPLETE_SCHEDULE_GO_LIVE;
                } else {
                    responseMessageKey = NotificationService.COMPLETE_GO_LIVE;
                }
                List<DmDependencyTO> submitToDeleteItems = new ArrayList<>();
                List<DmDependencyTO> goLiveItems = new ArrayList<>();
                List<DmDependencyTO> renameItems = new ArrayList<>();
                for (DmDependencyTO item : submittedItems) {
                    if (item.isSubmittedForDeletion()) {
                        submitToDeleteItems.add(item);
                    } else {
                        if (!isItemRenamed(site, item)) {
                            goLiveItems.add(item);
                        } else {
                            renameItems.add(item);
                        }
                    }
                }
                if (!submitToDeleteItems.isEmpty()) {
                    doDelete(site, submitToDeleteItems, approver);
                }
                if (!goLiveItems.isEmpty()) {
                    List<DmDependencyTO> references = getRefAndChildOfDiffDateFromParent(site, goLiveItems, true);
                    List<DmDependencyTO> children = getRefAndChildOfDiffDateFromParent(site, goLiveItems, false);
                    goLiveItems.addAll(references);
                    goLiveItems.addAll(children);
                    List<String> goLivePaths = new ArrayList<>();
                    Set<String> processedPaths = new HashSet<String>();
                    for (DmDependencyTO goLiveItem : goLiveItems) {
                        resolveSubmittedPaths(site, goLiveItem, goLivePaths, processedPaths);
                    }
                    List<String> nodeRefs = new ArrayList<>();
                    goLive(site, goLiveItems, approver, mcpContext);
                }
                if (!renameItems.isEmpty()) {
                    List<String> renamePaths = new ArrayList<>();
                    List<DmDependencyTO> renamedChildren = new ArrayList<>();
                    for (DmDependencyTO renameItem : renameItems) {
                        renamedChildren.addAll(getChildrenForRenamedItem(site, renameItem));
                        renamePaths.add(renameItem.getUri());
                        objectStateService.setSystemProcessing(site, renameItem.getUri(), true);
                    }
                    for (DmDependencyTO renamedChild : renamedChildren) {
                        renamePaths.add(renamedChild.getUri());
                        objectStateService.setSystemProcessing(site, renamedChild.getUri(), true);
                    }
                    renameItems.addAll(renamedChildren);
                    // Set proper information of all renameItems before send them to GoLive
                    for (int i = 0; i < renameItems.size(); i++) {
                        DmDependencyTO renamedItem = renameItems.get(i);
                        if (renamedItem.getScheduledDate() != null && renamedItem.getScheduledDate().isAfter(ZonedDateTime.now(ZoneOffset.UTC))) {
                            renamedItem.setNow(false);
                        } else {
                            renamedItem.setNow(true);
                        }
                        renameItems.set(i, renamedItem);
                    }
                    goLive(site, renameItems, approver, mcpContext);
                }
                break;
            case DELETE:
                responseMessageKey = NotificationService.COMPLETE_DELETE;
                List<String> deletePaths = new ArrayList<>();
                List<String> nodeRefs = new ArrayList<String>();
                for (DmDependencyTO deletedItem : submittedItems) {
                    deletePaths.add(deletedItem.getUri());
                    ContentItemTO contentItem = contentService.getContentItem(site, deletedItem.getUri());
                    if (contentItem != null) {
                    // nodeRefs.add(nodeRef.getId());
                    }
                }
                doDelete(site, submittedItems, approver);
        }
        result.setSuccess(true);
        result.setStatus(200);
        result.setMessage(notificationService.getNotificationMessage(site, NotificationMessageType.CompleteMessages, responseMessageKey, Locale.ENGLISH));
    } catch (JSONException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    } catch (ServiceLayerException e) {
        logger.error("error performing operation " + operation + " " + e);
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    }
    return result;
}
Also used : JSONArray(net.sf.json.JSONArray) ArrayList(java.util.ArrayList) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) JSONException(net.sf.json.JSONException) DmDependencyTO(org.craftercms.studio.api.v1.to.DmDependencyTO) ResultTO(org.craftercms.studio.api.v1.to.ResultTO) ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) MultiChannelPublishingContext(org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext) JSONObject(net.sf.json.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)4 MultiChannelPublishingContext (org.craftercms.studio.api.v1.service.workflow.context.MultiChannelPublishingContext)4 DmDependencyTO (org.craftercms.studio.api.v1.to.DmDependencyTO)4 SimpleDateFormat (java.text.SimpleDateFormat)3 HashSet (java.util.HashSet)3 JSONArray (net.sf.json.JSONArray)3 JSONException (net.sf.json.JSONException)3 JSONObject (net.sf.json.JSONObject)3 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)3 ResultTO (org.craftercms.studio.api.v1.to.ResultTO)3 ZonedDateTime (java.time.ZonedDateTime)2 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)1 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)1 DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)1 GoLiveContext (org.craftercms.studio.api.v1.service.workflow.context.GoLiveContext)1 AuditLog (org.craftercms.studio.api.v2.dal.AuditLog)1 AuditLogParameter (org.craftercms.studio.api.v2.dal.AuditLogParameter)1