RepositoryServiceImpl.java 4.1 KB
/*
 * 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;
            }
        };
    }

}