MobileApplicationOperation.java 2.56 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.granite.ui.components.HtmlResponse
 *  com.day.cq.contentsync.config.Config
 *  javax.jcr.RepositoryException
 *  javax.jcr.Session
 *  org.apache.commons.lang3.StringUtils
 *  org.apache.sling.api.resource.PersistenceException
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.cq.mobile.platform.impl.operations;

import com.adobe.cq.mobile.appcache.impl.AppCacheManager;
import com.adobe.cq.mobile.appcache.impl.AppCacheManagerAdapterFactory;
import com.adobe.cq.mobile.platform.impl.operations.MobileAbstractOperation;
import com.adobe.cq.mobile.platform.impl.utils.MobileUtil;
import com.adobe.granite.ui.components.HtmlResponse;
import com.day.cq.contentsync.config.Config;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;

public abstract class MobileApplicationOperation
extends MobileAbstractOperation {
    protected Config getContentSyncBuildConfig(Resource appResource, boolean requestingDevConfig) {
        Resource content = appResource.getChild("jcr:content");
        ValueMap properties = content.getValueMap();
        String configPN = requestingDevConfig ? "phonegap-build-exportTemplate-dev" : "phonegap-build-exportTemplate";
        String exportConfigPath = (String)properties.get(configPN, String.class);
        Config config = null;
        if (StringUtils.isNotBlank((CharSequence)exportConfigPath)) {
            exportConfigPath = MobileUtil.normalizePath(exportConfigPath, content);
            config = (Config)appResource.getResourceResolver().getResource(exportConfigPath).adaptTo(Config.class);
        }
        return config;
    }

    protected void clearContentSyncBuildCache(HtmlResponse response, Resource appInstance, boolean requestingDevConfig) throws RepositoryException, PersistenceException {
        Session session = (Session)appInstance.getResourceResolver().adaptTo(Session.class);
        Config config = this.getContentSyncBuildConfig(appInstance, requestingDevConfig);
        AppCacheManager appCacheManager = this.appCacheManagerAdapterFactory.getAdapter((Object)session, AppCacheManager.class);
        appCacheManager.clearCache(config);
        response.onDeleted(config.getPath());
    }
}