TranslationPlatformConfigurationImpl.java 3.67 KB
/*
 * 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;
    }
}