ProjectPayloadInfoBuilder.java
2.36 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.projects.api.Project
* com.adobe.granite.workflow.exec.InboxItem
* com.adobe.granite.workflow.payload.PayloadInfo
* com.adobe.granite.workflow.payload.PayloadInfo$PAYLOAD_TYPE
* com.adobe.granite.workflow.payload.PayloadInfoBuilder
* com.adobe.granite.workflow.payload.PayloadInfoBuilderContext
* org.apache.commons.lang.StringUtils
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.cq.projects.impl;
import com.adobe.cq.projects.api.Project;
import com.adobe.cq.projects.impl.servlet.ProjectServletUtil;
import com.adobe.granite.workflow.exec.InboxItem;
import com.adobe.granite.workflow.payload.PayloadInfo;
import com.adobe.granite.workflow.payload.PayloadInfoBuilder;
import com.adobe.granite.workflow.payload.PayloadInfoBuilderContext;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@Component
@Service(value={PayloadInfoBuilder.class})
public class ProjectPayloadInfoBuilder
implements PayloadInfoBuilder {
public PayloadInfo getPayloadInfo(PayloadInfoBuilderContext context) {
Project project;
Resource resource;
String payloadPath = null;
payloadPath = context.getInboxItem() != null ? context.getInboxItem().getContentPath() : context.getPayloadPath();
if (StringUtils.isNotBlank((String)payloadPath) && (resource = context.getResourceResolver().getResource(payloadPath)) != null && (project = (Project)resource.adaptTo(Project.class)) != null) {
PayloadInfo info = context.createPayloadInfo();
String detailsUrl = ProjectServletUtil.getProjectDetailsUrl(resource) + payloadPath;
info.setPath(payloadPath).setBrowserPath(detailsUrl).setTitle(project.getTitle()).setDescription(project.getDescription()).setPayloadType(PayloadInfo.PAYLOAD_TYPE.PROJECT.name()).setAssetFolderPath(project.getAssetFolder().getPath()).setThumbnailPath(project.getProjectCover().getPath()).setIsActive(project.isActive());
return info;
}
return null;
}
}