TranslationPlatformConfigurationImpl.java
3.67 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.PropertyOption
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.PropertiesUtil
* org.osgi.service.component.ComponentContext
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.wcm.translation.impl;
import com.adobe.cq.wcm.translation.impl.TranslationPlatformConfiguration;
import java.util.Dictionary;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(label="Translation Platform Configuration", description="Configures Translation Platform", metatype=1)
@Service
@Properties(value={@Property(name="service.vendor", value={"Adobe"}), @Property(name="syncTranslationState.schedulingFormat", label="Scheduler Cron ", description="Please specify cron format for changing the scheduling", value={"0 0 1 1/1 * ? *"}), @Property(name="syncTranslationState.lockTimeoutInMinutes", label="Sync lock timeout", description="Please specify value in minutes after which translation sync lock will timeout.", value={"1440"}), @Property(name="export.format", label="Export Format", value={"xml"}, description="Please specify the format for exporting translation jobs", options={@PropertyOption(value="XML", name="xml"), @PropertyOption(value="XLIFF 1.2", name="xliff_1.2"), @PropertyOption(value="XLIFF 2.0", name="xliff_2.0")})})
public class TranslationPlatformConfigurationImpl
implements TranslationPlatformConfiguration {
private static final Logger log = LoggerFactory.getLogger(TranslationPlatformConfigurationImpl.class);
private static String exportFormat = "xml";
private static String cronExpression = "";
private static long iSyncTimeout = 0;
@Activate
private void setup(ComponentContext context) {
try {
Dictionary properties = context.getProperties();
cronExpression = PropertiesUtil.toString(properties.get("syncTranslationState.schedulingFormat"), (String)"");
String strSyncTimeout = PropertiesUtil.toString(properties.get("syncTranslationState.lockTimeoutInMinutes"), (String)"");
iSyncTimeout = 0;
try {
iSyncTimeout = Long.parseLong(strSyncTimeout);
}
catch (NumberFormatException e) {
iSyncTimeout = 0;
}
exportFormat = PropertiesUtil.toString(properties.get("export.format"), (String)"xml");
if (log.isInfoEnabled()) {
log.info("Cron Expression: {}", (Object)cronExpression);
log.info("Sync Timeout: {}", (Object)iSyncTimeout);
log.info("Export Format: {}", (Object)exportFormat);
}
}
catch (Exception ex) {
log.error("Error while activating TranslationPlatformConfigurationImpl", (Throwable)ex);
}
}
@Override
public long getSyncTimeout() {
return iSyncTimeout;
}
@Override
public String getCronExpressionForSync() {
return cronExpression;
}
@Override
public String getExportFormat() {
return exportFormat;
}
}