RequestLaunchPromotionParameters.java
3.79 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
79
80
81
82
83
84
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.launches.api.Launch
* com.adobe.cq.launches.api.LaunchException
* com.adobe.cq.launches.api.LaunchManager
* com.adobe.cq.launches.api.LaunchPromotionScope
* org.apache.commons.lang.StringUtils
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.cq.wcm.launches.impl;
import com.adobe.cq.launches.api.Launch;
import com.adobe.cq.launches.api.LaunchException;
import com.adobe.cq.launches.api.LaunchManager;
import com.adobe.cq.launches.api.LaunchPromotionScope;
import com.adobe.cq.wcm.launches.impl.AbstractLaunchPromotionParameters;
import com.adobe.cq.wcm.launches.utils.LaunchUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
public class RequestLaunchPromotionParameters
extends AbstractLaunchPromotionParameters {
private String workflowPackagePath;
public RequestLaunchPromotionParameters(SlingHttpServletRequest request) throws LaunchException {
String targetPath;
String path = request.getParameter("path");
if (StringUtils.isEmpty((String)path)) {
throw new LaunchException("Master path needs to be specified.");
}
this.resource = request.getResourceResolver().getResource(path);
if (this.resource == null) {
throw new LaunchException("Master path does not resolve to a resource.");
}
LaunchManager launchManager = (LaunchManager)request.getResourceResolver().adaptTo(LaunchManager.class);
this.launch = launchManager.getLaunch(LaunchUtils.getLaunchResource(this.resource).getPath());
String promotionScopeString = request.getParameter("promotionScope");
if (StringUtils.isEmpty((String)promotionScopeString)) {
throw new LaunchException("Incomplete request: Launch promotion scope not specified.");
}
try {
this.promotionScope = LaunchPromotionScope.valueOf((String)promotionScopeString.toUpperCase());
}
catch (IllegalArgumentException e) {
throw new LaunchException("Unrecognized launch promotion scope: " + promotionScopeString);
}
if (this.promotionScope.equals((Object)LaunchPromotionScope.RESOURCE) && "true".equals(request.getParameter("includeSubPages"))) {
this.promotionScope = LaunchPromotionScope.DEEP;
}
if ((targetPath = request.getParameter("target")) != null) {
Resource launchResource = request.getResourceResolver().getResource(targetPath);
if (launchResource == null) {
throw new LaunchException("Invalid path: " + targetPath);
}
this.target = (Launch)launchResource.adaptTo(Launch.class);
if (this.target == null) {
throw new LaunchException("Specified target path is not a launch: " + targetPath);
}
}
this.workflowPackagePath = request.getParameter("workflowPackage");
}
public String getResourceCollectionPath() {
return this.workflowPackagePath;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("LaunchPromotionParameters => {\n");
sb.append("\tresource: ").append(this.getResource().getPath()).append("\n");
sb.append("\tpromotionScope: ").append(this.getPromotionScope().getValue()).append("\n");
sb.append("\tworkflowPackagePath: ").append(this.getResourceCollectionPath()).append("\n");
sb.append("\tisDeep: ").append(this.isDeep()).append("\n");
sb.append("}\n");
return sb.toString();
}
}