LinkArticleToSharedResourceEntity.java 2.46 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.dps.client.producer.EntityProducerDAO
 *  com.adobe.dps.client.producer.api.ProducerApi
 *  com.adobe.dps.client.producer.utils.AccessToken
 *  com.adobe.dps.client.producer.utils.Session
 *  com.adobe.dps.producer.entity.dto.ArticleEntity
 *  com.adobe.dps.producer.entity.dto.Entity
 *  com.adobe.dps.producer.entity.dto.SharedContentEntity
 *  org.slf4j.Logger
 */
package com.adobe.cq.mobile.dps.impl.service.actions;

import com.adobe.cq.mobile.dps.impl.service.actions.AbstractCallableDPSAction;
import com.adobe.cq.mobile.dps.impl.ui.PerfTimer;
import com.adobe.dps.client.producer.EntityProducerDAO;
import com.adobe.dps.client.producer.api.ProducerApi;
import com.adobe.dps.client.producer.utils.AccessToken;
import com.adobe.dps.client.producer.utils.Session;
import com.adobe.dps.producer.entity.dto.ArticleEntity;
import com.adobe.dps.producer.entity.dto.Entity;
import com.adobe.dps.producer.entity.dto.SharedContentEntity;
import java.util.concurrent.Callable;
import org.slf4j.Logger;

public class LinkArticleToSharedResourceEntity
extends AbstractCallableDPSAction
implements Callable<ArticleEntity> {
    private final ProducerApi producerApi;
    private final String entityHref;
    private final SharedContentEntity sharedContentEntity;

    public LinkArticleToSharedResourceEntity(EntityProducerDAO entityAccess, ProducerApi producerAPI, AccessToken accessToken, Session session, String entityHref, SharedContentEntity sharedContentEntity) {
        super(entityAccess, accessToken, session);
        this.producerApi = producerAPI;
        this.entityHref = entityHref;
        this.sharedContentEntity = sharedContentEntity;
    }

    @Override
    public ArticleEntity call() throws Exception {
        PerfTimer perfTimer = PerfTimer.startTimer(this, this.getClass().getName());
        this.logger.debug("Linking article for shared resources " + this.entityHref);
        ArticleEntity article = (ArticleEntity)this.entityAccess.readEntity(this.accessToken, this.entityHref, this.session.generateNewRequestId());
        if (article != null) {
            article = this.producerApi.linkArticleToSharedContent(article, this.sharedContentEntity, "HTMLResources", this.session);
        } else {
            this.logger.warn("Referenced entity does not exist in AEM Mobile On Demand and cannot be linked, " + this.entityHref);
        }
        perfTimer.end();
        return article;
    }
}