AbstractCallableDPSAction.java
3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* 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.EntityUtils
* com.adobe.dps.client.producer.utils.Session
* com.adobe.dps.producer.entity.dto.Entity
* com.adobe.dps.producer.entity.dto.EntityList
* com.adobe.dps.producer.entity.dto.StatusList
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.dps.impl.service.actions;
import com.adobe.cq.mobile.dps.DPSException;
import com.adobe.cq.mobile.dps.impl.ui.PerfTimer;
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.EntityUtils;
import com.adobe.dps.client.producer.utils.Session;
import com.adobe.dps.producer.entity.dto.Entity;
import com.adobe.dps.producer.entity.dto.EntityList;
import com.adobe.dps.producer.entity.dto.StatusList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractCallableDPSAction {
protected final Logger logger;
protected final EntityProducerDAO entityAccess;
protected final AccessToken accessToken;
protected final Session session;
AbstractCallableDPSAction(EntityProducerDAO entityAccess, AccessToken accessToken, Session session) {
this.entityAccess = entityAccess;
this.accessToken = accessToken;
this.session = new Session(session);
this.logger = LoggerFactory.getLogger(this.getClass());
}
protected Entity getEntity(String entityURI) throws ProducerException, ProducerRequestException, DPSException {
PerfTimer perfTimer = PerfTimer.startTimer(this, "entityAccess.readEntity");
Entity entity = this.entityAccess.readEntity(this.accessToken, entityURI, this.session);
if (entity == null) {
throw new DPSException("Entity not found for " + entityURI);
}
perfTimer.end();
return entity;
}
protected EntityList getContentElements(String entityURI) throws ProducerException, ProducerRequestException {
PerfTimer perfTimer = PerfTimer.startTimer(this, "entityAccess.getContentElements");
EntityList contentElements = this.entityAccess.getContentElements(this.accessToken, entityURI, this.session);
contentElements = EntityUtils.filter((EntityList)contentElements, (EntityType[])new EntityType[]{EntityType.ARTICLE, EntityType.COLLECTION, EntityType.BANNER});
perfTimer.end();
return contentElements;
}
protected EntityList getReferringEntities(String entityURI, EntityType entityType) throws ProducerException, ProducerRequestException {
PerfTimer perfTimer = PerfTimer.startTimer(this, "entityAccess.getReferringEntities");
EntityList referringEntities = this.entityAccess.getReferringEntities(this.accessToken, entityURI, entityType, this.session);
perfTimer.end();
return referringEntities;
}
protected StatusList getStatus(String entityURI) throws ProducerException, ProducerRequestException {
PerfTimer perfTimer = PerfTimer.startTimer(this, "entityAccess.getEntityStatus");
StatusList status = this.entityAccess.getEntityStatus(this.accessToken, entityURI, this.session);
perfTimer.end();
return status;
}
}