GetReferences.java 2.42 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.dps.client.producer.EntityProducerDAO
 *  com.adobe.dps.client.producer.EntityType
 *  com.adobe.dps.client.producer.exceptions.ProducerException
 *  com.adobe.dps.client.producer.exceptions.ProducerRequestException
 *  com.adobe.dps.client.producer.utils.AccessToken
 *  com.adobe.dps.client.producer.utils.Session
 *  com.adobe.dps.producer.entity.dto.EntityList
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.JSONObject
 */
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.cq.mobile.dps.impl.utils.MetadataJSONUtil;
import com.adobe.dps.client.producer.EntityProducerDAO;
import com.adobe.dps.client.producer.EntityType;
import com.adobe.dps.client.producer.exceptions.ProducerException;
import com.adobe.dps.client.producer.exceptions.ProducerRequestException;
import com.adobe.dps.client.producer.utils.AccessToken;
import com.adobe.dps.client.producer.utils.Session;
import com.adobe.dps.producer.entity.dto.EntityList;
import java.util.concurrent.Callable;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

public class GetReferences
extends AbstractCallableDPSAction
implements Callable<JSONObject> {
    public static final String KEY_ID = "id";
    public static final String KEY_REFERENCES = "references";
    private final String entityHref;

    public GetReferences(EntityProducerDAO entityAccess, AccessToken accessToken, Session session, String entityHref) {
        super(entityAccess, accessToken, session);
        this.entityHref = entityHref;
    }

    @Override
    public JSONObject call() throws Exception {
        return this.getReferences();
    }

    private JSONObject getReferences() throws ProducerException, ProducerRequestException, JSONException {
        PerfTimer perfTimer = PerfTimer.startTimer(this, this.getClass().getName());
        EntityList referringEntities = this.getReferringEntities(this.entityHref, EntityType.COLLECTION);
        JSONObject statusJSON = new JSONObject();
        statusJSON.put("id", (Object)this.entityHref);
        statusJSON.put("references", (Object)MetadataJSONUtil.getReferringEntitiesJSON(referringEntities));
        perfTimer.end();
        return statusJSON;
    }
}