Scene7Importer.java
3.19 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
81
82
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.polling.importer.ImportException
* com.day.cq.polling.importer.Importer
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Modified
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.commons.osgi.OsgiUtil
* org.osgi.service.component.ComponentContext
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.dam.scene7.impl.importer;
import com.day.cq.dam.scene7.api.S7Config;
import com.day.cq.dam.scene7.api.importer.Scene7ImportService;
import com.day.cq.polling.importer.ImportException;
import com.day.cq.polling.importer.Importer;
import java.util.Dictionary;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=1)
@Service
@Properties(value={@Property(name="importer.scheme", value={"scene7"}, propertyPrivate=1)})
public class Scene7Importer
implements Importer {
static final String IMPORTER_SCHEME = "scene7";
private static final Logger LOG = LoggerFactory.getLogger(Scene7Importer.class);
@Reference
private Scene7ImportService scene7ImportService;
@Property(boolValue={0})
private static final String IMPORTER_ENABLED = "cq.dam.scene7.importer.enabled";
private boolean importerEnabled = false;
public void importData(String scheme, String dataSource, Resource target) throws ImportException {
if (this.importerEnabled) {
LOG.debug("Polling import using scheme = {}, dataSource = {}", (Object)scheme, (Object)dataSource);
Resource scene7ConfigResource = target.getParent();
S7Config s7Config = (S7Config)scene7ConfigResource.adaptTo(S7Config.class);
if (s7Config != null) {
this.scene7ImportService.importAssets(s7Config);
}
} else {
LOG.debug("Polling importer is disabled");
}
}
@Activate
@Modified
protected void activate(ComponentContext componentContext) {
this.importerEnabled = OsgiUtil.toBoolean(componentContext.getProperties().get("cq.dam.scene7.importer.enabled"), (boolean)false);
}
protected void bindScene7ImportService(Scene7ImportService scene7ImportService) {
this.scene7ImportService = scene7ImportService;
}
protected void unbindScene7ImportService(Scene7ImportService scene7ImportService) {
if (this.scene7ImportService == scene7ImportService) {
this.scene7ImportService = null;
}
}
}