RepositoryServiceImpl.java
4.1 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.forms.external.service.RepositoryService
* com.adobe.forms.external.service.ResourceVO
* com.adobe.idp.Document
* com.adobe.idp.dsc.clientsdk.ServiceClientFactory
* com.adobe.repository.RepositoryException
* com.adobe.repository.RepositoryLoadProfile
* com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient
* com.adobe.repository.infomodel.bean.Resource
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.forms.livecycle.impl;
import com.adobe.forms.external.service.RepositoryService;
import com.adobe.forms.external.service.ResourceVO;
import com.adobe.forms.livecycle.impl.ServiceClientFactoryProviderImpl;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.repository.RepositoryException;
import com.adobe.repository.RepositoryLoadProfile;
import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
import com.adobe.repository.infomodel.bean.Resource;
import java.io.InputStream;
import java.util.Date;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(label="RepositoryService", description="RepositoryService")
@Service(value={RepositoryServiceImpl.class})
public class RepositoryServiceImpl
implements RepositoryService {
Logger logger = LoggerFactory.getLogger(RepositoryServiceImpl.class);
@Reference
private ServiceClientFactoryProviderImpl serviceClientFactoryProvider;
protected void bindServiceClientFactoryProvider(ServiceClientFactoryProviderImpl serviceClientFactoryProvider) {
this.serviceClientFactoryProvider = serviceClientFactoryProvider;
}
protected void unbindServiceClientFactoryProvider(ServiceClientFactoryProviderImpl serviceClientFactoryProvider) {
this.serviceClientFactoryProvider = serviceClientFactoryProvider;
}
public InputStream getResourceContentAsStream(String path) throws RepositoryException {
this.logger.debug("RepositoryServiceImpl#getReesourceContentAsStream " + path);
ResourceRepositoryClient client = new ResourceRepositoryClient(this.serviceClientFactoryProvider.getDefaultServiceClientFactory());
RepositoryLoadProfile loadProfile = new RepositoryLoadProfile(false);
loadProfile.project(31);
loadProfile.project(34);
loadProfile.project(50);
client.setLoadProfile(loadProfile);
return client.readResourceContent(path).getInputStream();
}
public Date getResourceUpdateTime(String path) throws RepositoryException {
this.logger.debug("RepositoryServiceImpl#getResourceUpdateTime " + path);
ResourceRepositoryClient client = new ResourceRepositoryClient(this.serviceClientFactoryProvider.getDefaultServiceClientFactory());
RepositoryLoadProfile loadProfile = new RepositoryLoadProfile(false);
loadProfile.project(31);
loadProfile.project(34);
loadProfile.project(50);
client.setLoadProfile(loadProfile);
Resource resource = null;
try {
resource = client.readResource(path);
}
catch (RepositoryException e) {
this.logger.debug("RepositoryServiceImpl#getResourceUpdateTime: Error reading resource " + path, (Throwable)e);
}
if (resource != null) {
return resource.getUpdateTime();
}
return new Date(Long.MAX_VALUE);
}
public String getProtocol() {
return "repository";
}
public ResourceVO getResource(String path) throws Exception {
final InputStream is = this.getResourceContentAsStream(path);
return new ResourceVO(){
public boolean isTrusted() {
return true;
}
public InputStream getInputStream() {
return is;
}
};
}
}