Search in sources :

Example 1 with MinifiedCssFile

use of org.structr.web.entity.MinifiedCssFile in project structr by structr.

the class DeployCommand method exportFileConfiguration.

private void exportFileConfiguration(final AbstractFile abstractFile, final Map<String, Object> config) {
    if (abstractFile.isVisibleToPublicUsers()) {
        putIf(config, "visibleToPublicUsers", true);
    }
    if (abstractFile.isVisibleToAuthenticatedUsers()) {
        putIf(config, "visibleToAuthenticatedUsers", true);
    }
    if (abstractFile instanceof File) {
        final File file = (File) abstractFile;
        if (file.isTemplate()) {
            putIf(config, "isTemplate", true);
        }
    }
    putIf(config, "type", abstractFile.getProperty(File.type));
    putIf(config, "contentType", abstractFile.getProperty(StructrApp.key(File.class, "contentType")));
    putIf(config, "cacheForSeconds", abstractFile.getProperty(StructrApp.key(File.class, "cacheForSeconds")));
    putIf(config, "useAsJavascriptLibrary", abstractFile.getProperty(StructrApp.key(File.class, "useAsJavascriptLibrary")));
    putIf(config, "includeInFrontendExport", abstractFile.getProperty(StructrApp.key(File.class, "includeInFrontendExport")));
    putIf(config, "basicAuthRealm", abstractFile.getProperty(StructrApp.key(File.class, "basicAuthRealm")));
    putIf(config, "enableBasicAuth", abstractFile.getProperty(StructrApp.key(File.class, "enableBasicAuth")));
    if (abstractFile instanceof Image) {
        final Image image = (Image) abstractFile;
        putIf(config, "isThumbnail", image.isThumbnail());
        putIf(config, "isImage", image.isImage());
        putIf(config, "width", image.getWidth());
        putIf(config, "height", image.getHeight());
    }
    if (abstractFile instanceof AbstractMinifiedFile) {
        if (abstractFile instanceof MinifiedCssFile) {
            final MinifiedCssFile mcf = (MinifiedCssFile) abstractFile;
            putIf(config, "lineBreak", mcf.getLineBreak());
        }
        if (abstractFile instanceof MinifiedJavaScriptFile) {
            final MinifiedJavaScriptFile mjf = (MinifiedJavaScriptFile) abstractFile;
            putIf(config, "optimizationLevel", mjf.getOptimizationLevel());
        }
        final Class<Relation> relType = StructrApp.getConfiguration().getRelationshipEntityClass("AbstractMinifiedFileMINIFICATIONFile");
        final PropertyKey<Integer> positionKey = StructrApp.key(relType, "position");
        final Map<Integer, String> minifcationSources = new TreeMap<>();
        for (Relation minificationSourceRel : AbstractMinifiedFile.getSortedRelationships((AbstractMinifiedFile) abstractFile)) {
            final File file = (File) minificationSourceRel.getTargetNode();
            minifcationSources.put(minificationSourceRel.getProperty(positionKey), file.getPath());
        }
        putIf(config, "minificationSources", minifcationSources);
    }
    // export all dynamic properties
    for (final PropertyKey key : StructrApp.getConfiguration().getPropertySet(abstractFile.getClass(), PropertyView.All)) {
        // only export dynamic (=> additional) keys
        if (!key.isPartOfBuiltInSchema()) {
            putIf(config, key.jsonName(), abstractFile.getProperty(key));
        }
    }
    exportOwnershipAndSecurity(abstractFile, config);
}
Also used : Image(org.structr.web.entity.Image) TreeMap(java.util.TreeMap) MinifiedCssFile(org.structr.web.entity.MinifiedCssFile) Relation(org.structr.core.entity.Relation) AbstractMinifiedFile(org.structr.web.entity.AbstractMinifiedFile) MinifiedJavaScriptFile(org.structr.web.entity.MinifiedJavaScriptFile) AbstractFile(org.structr.web.entity.AbstractFile) AbstractMinifiedFile(org.structr.web.entity.AbstractMinifiedFile) MinifiedCssFile(org.structr.web.entity.MinifiedCssFile) File(org.structr.web.entity.File) MinifiedJavaScriptFile(org.structr.web.entity.MinifiedJavaScriptFile) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

TreeMap (java.util.TreeMap)1 Relation (org.structr.core.entity.Relation)1 PropertyKey (org.structr.core.property.PropertyKey)1 AbstractFile (org.structr.web.entity.AbstractFile)1 AbstractMinifiedFile (org.structr.web.entity.AbstractMinifiedFile)1 File (org.structr.web.entity.File)1 Image (org.structr.web.entity.Image)1 MinifiedCssFile (org.structr.web.entity.MinifiedCssFile)1 MinifiedJavaScriptFile (org.structr.web.entity.MinifiedJavaScriptFile)1