GuideBatchDraftStateProviderImpl.java
2.19 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.guide.service.GuideDraftStateProvider
* com.adobe.aemds.guide.service.GuideException
* com.adobe.aemds.guide.storage.api.StorageProvider
* com.adobe.aemfd.docmanager.Document
* org.apache.commons.io.IOUtils
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
*/
package com.adobe.aemds.guide.batch.impl;
import com.adobe.aemds.guide.service.GuideDraftStateProvider;
import com.adobe.aemds.guide.service.GuideException;
import com.adobe.aemds.guide.storage.api.StorageProvider;
import com.adobe.aemfd.docmanager.Document;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
@Component(immediate=1, metatype=1, label="Adaptive Document Guide Draft State Provider", description="Guide draft state provider service for Adaptive Document batch.")
@Service(value={GuideDraftStateProvider.class})
public class GuideBatchDraftStateProviderImpl
implements GuideDraftStateProvider {
@Reference
private StorageProvider storageProvider;
public String getGuideDraftState(String guideStatePathRef) throws GuideException {
try {
if (!this.storageProvider.isProviderOwned(guideStatePathRef)) {
return null;
}
Document guideDraftState = this.storageProvider.resolve(guideStatePathRef, false);
String result = null;
if (guideDraftState != null) {
result = IOUtils.toString((InputStream)guideDraftState.getInputStream());
}
return result;
}
catch (Exception ex) {
throw new GuideException(ex);
}
}
protected void bindStorageProvider(StorageProvider storageProvider) {
this.storageProvider = storageProvider;
}
protected void unbindStorageProvider(StorageProvider storageProvider) {
if (this.storageProvider == storageProvider) {
this.storageProvider = null;
}
}
}