LinkingStatusServiceImpl.java 1.61 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.i18n.I18n
 *  com.day.cq.wcm.api.Page
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.resource.Resource
 */
package com.adobe.cq.mcm.campaign.impl;

import com.adobe.cq.mcm.campaign.LinkingStatus;
import com.adobe.cq.mcm.campaign.LinkingStatusService;
import com.adobe.cq.mcm.campaign.NewsletterException;
import com.adobe.cq.mcm.campaign.NewsletterManager;
import com.day.cq.i18n.I18n;
import com.day.cq.wcm.api.Page;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;

@Component(metatype=0)
@Service
public class LinkingStatusServiceImpl
implements LinkingStatusService {
    @Reference
    private NewsletterManager manager;

    @Override
    public LinkingStatus retrieveStatus(Resource resource, I18n i18n) throws NewsletterException {
        Page page = (Page)resource.getParent().adaptTo(Page.class);
        String[] links = this.manager.getLinkedDeliveries(page);
        boolean isApproved = this.manager.isApproved(page);
        return new LinkingStatus(isApproved, links);
    }

    protected void bindManager(NewsletterManager newsletterManager) {
        this.manager = newsletterManager;
    }

    protected void unbindManager(NewsletterManager newsletterManager) {
        if (this.manager == newsletterManager) {
            this.manager = null;
        }
    }
}