Scene7GenericImportHandler.java
2.4 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.dam.api.Asset
* javax.jcr.Session
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.jcr.resource.JcrResourceResolverFactory
*/
package com.day.cq.dam.scene7.impl.importer;
import com.day.cq.dam.api.Asset;
import com.day.cq.dam.scene7.api.S7Config;
import com.day.cq.dam.scene7.api.constants.Scene7AssetType;
import com.day.cq.dam.scene7.api.importer.Scene7ImportHandler;
import com.day.cq.dam.scene7.api.model.Scene7Asset;
import com.day.cq.dam.scene7.impl.importer.Scene7AbstractImportHandler;
import java.util.Date;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
@Component(metatype=1, label="%cq.dam.scene7.genericimporthandler.name", description="%cq.dam.scene7.genericimporthandler.description")
@Service(value={Scene7ImportHandler.class})
public class Scene7GenericImportHandler
extends Scene7AbstractImportHandler {
@Property(name="scene7.asset.type")
public static final String SCR_PROP_VALUE_S7_ASSET_TYPE = Scene7AssetType.GENERIC.getValue();
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public Asset importAsset(Scene7Asset asset, S7Config s7Config) throws Exception {
Asset damAsset = null;
if (asset == null) {
throw new NullPointerException("Null asset");
}
if (s7Config == null) {
throw new NullPointerException("Null Scene7 configuration");
}
ResourceResolver rr = null;
Session session = null;
try {
session = this.getSlingScene7AssetServiceSession();
rr = this.resourceResolverFactory.getResourceResolver(session);
damAsset = this.createOrUpdateAsset(rr, s7Config, asset, asset.getModifiedDate().getTime());
}
finally {
if (rr != null) {
rr.close();
}
if (session != null) {
session.logout();
}
}
return damAsset;
}
}