Search in sources :

Example 1 with PublishingPackageDetails

use of org.craftercms.studio.api.v2.dal.PublishingPackageDetails in project studio by craftercms.

the class PublishServiceInternalImpl method getPublishingPackageDetails.

@Override
public PublishingPackageDetails getPublishingPackageDetails(String siteId, String packageId) {
    List<PublishRequest> publishingRequests = publishRequestDao.getPublishingPackageDetails(siteId, packageId);
    PublishingPackageDetails publishingPackageDetails = new PublishingPackageDetails();
    List<PublishingPackageDetails.PublishingPackageItem> packageItems = new ArrayList<PublishingPackageDetails.PublishingPackageItem>();
    if (CollectionUtils.isNotEmpty(publishingRequests)) {
        PublishRequest pr = publishingRequests.get(0);
        publishingPackageDetails.setSiteId(pr.getSite());
        publishingPackageDetails.setPackageId(pr.getPackageId());
        publishingPackageDetails.setEnvironment(pr.getEnvironment());
        publishingPackageDetails.setState(pr.getState());
        publishingPackageDetails.setScheduledDate(pr.getScheduledDate());
        publishingPackageDetails.setUser(pr.getUser());
        publishingPackageDetails.setComment(pr.getSubmissionComment());
    }
    for (PublishRequest publishRequest : publishingRequests) {
        PublishingPackageDetails.PublishingPackageItem item = new PublishingPackageDetails.PublishingPackageItem();
        item.setPath(publishRequest.getPath());
        item.setContentTypeClass(publishRequest.getContentTypeClass());
        packageItems.add(item);
    }
    publishingPackageDetails.setItems(packageItems);
    return publishingPackageDetails;
}
Also used : ArrayList(java.util.ArrayList) PublishRequest(org.craftercms.studio.api.v2.dal.PublishRequest) PublishingPackageDetails(org.craftercms.studio.api.v2.dal.PublishingPackageDetails)

Example 2 with PublishingPackageDetails

use of org.craftercms.studio.api.v2.dal.PublishingPackageDetails in project studio by craftercms.

the class PublishController method getPublishingPackageDetails.

@GetMapping(PACKAGE)
public ResponseBody getPublishingPackageDetails(@RequestParam(name = REQUEST_PARAM_SITEID) String siteId, @RequestParam(name = REQUEST_PARAM_PACKAGE_ID) String packageId) throws SiteNotFoundException {
    if (!siteService.exists(siteId)) {
        throw new SiteNotFoundException(siteId);
    }
    PublishingPackageDetails publishingPackageDetails = publishService.getPublishingPackageDetails(siteId, packageId);
    ResponseBody responseBody = new ResponseBody();
    ResultOne<PublishingPackageDetails> result = new ResultOne<PublishingPackageDetails>();
    result.setEntity(RESULT_KEY_PACKAGE, publishingPackageDetails);
    result.setResponse(OK);
    responseBody.setResult(result);
    return responseBody;
}
Also used : ResultOne(org.craftercms.studio.model.rest.ResultOne) PublishingPackageDetails(org.craftercms.studio.api.v2.dal.PublishingPackageDetails) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with PublishingPackageDetails

use of org.craftercms.studio.api.v2.dal.PublishingPackageDetails in project studio by craftercms.

the class PublishServiceImpl method cancelPublishingPackages.

@Override
@HasPermission(type = DefaultPermission.class, action = ACTION_CANCEL_PUBLISH)
public void cancelPublishingPackages(@ProtectedResourceId(SITE_ID_RESOURCE_ID) String siteId, List<String> packageIds) throws SiteNotFoundException {
    if (!siteService.exists(siteId)) {
        throw new SiteNotFoundException(siteId);
    }
    publishServiceInternal.cancelPublishingPackages(siteId, packageIds);
    List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
    for (String pId : packageIds) {
        PublishingPackageDetails packageDetails = publishServiceInternal.getPublishingPackageDetails(siteId, pId);
        List<String> paths = new ArrayList<String>();
        for (PublishingPackageDetails.PublishingPackageItem item : packageDetails.getItems()) {
            paths.add(item.getPath());
            ItemMetadata itemMetadata = objectMetadataManager.getProperties(siteId, item.getPath());
            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);
            }
            AuditLogParameter auditLogParameter = new AuditLogParameter();
            auditLogParameter.setTargetId(siteId + ":" + item.getPath());
            auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
            auditLogParameter.setTargetValue(item.getPath());
            auditLogParameters.add(auditLogParameter);
        }
        objectStateService.transitionBulk(siteId, paths, REJECT, NEW_UNPUBLISHED_UNLOCKED);
        createAuditLogEntry(siteId, auditLogParameters);
    }
}
Also used : ArrayList(java.util.ArrayList) AuditLogParameter(org.craftercms.studio.api.v2.dal.AuditLogParameter) PublishingPackageDetails(org.craftercms.studio.api.v2.dal.PublishingPackageDetails) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata) HasPermission(org.craftercms.commons.security.permissions.annotations.HasPermission)

Aggregations

PublishingPackageDetails (org.craftercms.studio.api.v2.dal.PublishingPackageDetails)3 ArrayList (java.util.ArrayList)2 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)2 HasPermission (org.craftercms.commons.security.permissions.annotations.HasPermission)1 ItemMetadata (org.craftercms.studio.api.v1.dal.ItemMetadata)1 AuditLogParameter (org.craftercms.studio.api.v2.dal.AuditLogParameter)1 PublishRequest (org.craftercms.studio.api.v2.dal.PublishRequest)1 ResponseBody (org.craftercms.studio.model.rest.ResponseBody)1 ResultOne (org.craftercms.studio.model.rest.ResultOne)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1