PromoteLaunchCommand.java
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.launches.api.Launch
* com.adobe.cq.launches.api.LaunchManager
* com.adobe.cq.launches.api.LaunchManagerFactory
* com.adobe.cq.launches.api.LaunchPromotionParameters
* com.day.cq.commons.servlets.HtmlStatusResponseHelper
* com.day.cq.wcm.api.PageManager
* com.day.cq.wcm.api.commands.WCMCommandContext
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.SlingHttpServletResponse
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.servlets.HtmlResponse
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.wcm.launches.impl.commands;
import com.adobe.cq.launches.api.Launch;
import com.adobe.cq.launches.api.LaunchManager;
import com.adobe.cq.launches.api.LaunchManagerFactory;
import com.adobe.cq.launches.api.LaunchPromotionParameters;
import com.adobe.cq.wcm.launches.impl.RequestLaunchPromotionParameters;
import com.adobe.cq.wcm.launches.impl.commands.LaunchesCommand;
import com.adobe.cq.wcm.launches.utils.LaunchUtils;
import com.day.cq.commons.servlets.HtmlStatusResponseHelper;
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.commands.WCMCommandContext;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.servlets.HtmlResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
@Service
public class PromoteLaunchCommand
extends LaunchesCommand {
private final Logger log = LoggerFactory.getLogger(PromoteLaunchCommand.class);
public static final String PROMOTION_SCOPE_PARAM = "promotionScope";
public static final String TARGET_PARAM = "target";
public static final String INCLUDE_SUB_PAGES_PARAM = "includeSubPages";
public static final String WORKFLOW_PACKAGE_PARAM = "workflowPackage";
public String getCommandName() {
return "promoteLaunch";
}
public HtmlResponse performCommand(WCMCommandContext ctx, SlingHttpServletRequest request, SlingHttpServletResponse response, PageManager pageManager) {
try {
RequestLaunchPromotionParameters params = new RequestLaunchPromotionParameters(request);
Resource resource = params.getResource();
LaunchManager launchManager = this.launchesManagerFactory.getLaunchManager(request.getResourceResolver());
Resource lRes = LaunchUtils.getLaunchResource(resource);
if (lRes == null) {
return HtmlStatusResponseHelper.createStatusResponse((boolean)false, (String)("Error during operation. Provided path is not part of a launch: " + resource.getPath()));
}
Launch l = (Launch)lRes.adaptTo(Launch.class);
launchManager.promoteLaunch(l, (LaunchPromotionParameters)params);
return HtmlStatusResponseHelper.createStatusResponse((boolean)true, (String)"Launch promoted", (String)LaunchUtils.getTargetResource(params.getResource(), params.getTarget()).getPath());
}
catch (Exception e) {
String msg = "Error while promoting launch";
this.log.error(msg, (Throwable)e);
return HtmlStatusResponseHelper.createStatusResponse((boolean)false, (String)msg);
}
}
}