DPSConnectionAdapterFactory.java
4.3 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.crypto.CryptoSupport
* com.day.cq.wcm.webservicesupport.Configuration
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.LoginException
* org.apache.sling.api.resource.ResourceResolverFactory
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.dps.impl.service;
import com.adobe.cq.mobile.dps.DPSObject;
import com.adobe.cq.mobile.dps.DPSProject;
import com.adobe.cq.mobile.dps.impl.DPSConnection;
import com.adobe.cq.mobile.dps.impl.service.AdobeDPSClient;
import com.adobe.cq.mobile.dps.impl.service.DPSConnectionImpl;
import com.adobe.cq.mobile.dps.impl.utils.DPSUtil;
import com.adobe.granite.crypto.CryptoSupport;
import com.day.cq.wcm.webservicesupport.Configuration;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0)
@Service(value={DPSConnectionAdapterFactory.class})
public class DPSConnectionAdapterFactory {
private static Logger log = LoggerFactory.getLogger(DPSConnectionAdapterFactory.class);
@Property(name="adapters", propertyPrivate=1)
private static final String[] ADAPTER_CLASSES = new String[]{DPSConnection.class.getName()};
@Property(name="adaptables", propertyPrivate=1)
private static final String[] ADAPTABLE_CLASSES = new String[]{DPSObject.class.getName(), Configuration.class.getName()};
@Reference
private ResourceResolverFactory resourceResolverFactory;
@Reference
private CryptoSupport cryptoSupportService;
@Reference
private AdobeDPSClient adobePublishClient;
public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
if (DPSConnection.class == type) {
try {
if (adaptable instanceof DPSObject) {
DPSObject dpsObject = (DPSObject)adaptable;
DPSProject dpsProject = DPSUtil.getDPSProject(dpsObject);
Configuration configuration = dpsProject.getDPSConfiguration();
return (AdapterType)this.getDPSConnection(configuration);
}
if (adaptable instanceof Configuration) {
Configuration configuration = (Configuration)adaptable;
return (AdapterType)this.getDPSConnection(configuration);
}
log.error("Can't adapt {} to DPSConnection", (Object)(adaptable == null ? "null" : adaptable.getClass().getName()));
}
catch (Exception ex) {
log.error("Unable to obtain the DPSConnection", (Throwable)ex);
}
}
return null;
}
private DPSConnection getDPSConnection(Configuration configuration) throws LoginException {
return new DPSConnectionImpl(configuration, this.adobePublishClient);
}
protected void bindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
this.resourceResolverFactory = resourceResolverFactory;
}
protected void unbindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
if (this.resourceResolverFactory == resourceResolverFactory) {
this.resourceResolverFactory = null;
}
}
protected void bindCryptoSupportService(CryptoSupport cryptoSupport) {
this.cryptoSupportService = cryptoSupport;
}
protected void unbindCryptoSupportService(CryptoSupport cryptoSupport) {
if (this.cryptoSupportService == cryptoSupport) {
this.cryptoSupportService = null;
}
}
protected void bindAdobePublishClient(AdobeDPSClient adobeDPSClient) {
this.adobePublishClient = adobeDPSClient;
}
protected void unbindAdobePublishClient(AdobeDPSClient adobeDPSClient) {
if (this.adobePublishClient == adobeDPSClient) {
this.adobePublishClient = null;
}
}
}