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