GuideBatchDraftStateProviderImpl.java 2.19 KB
/*
 * 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;
        }
    }
}