ilscipio/scipio-erp

View on GitHub
applications/content/servicedef/services_image.xml

Summary

Maintainability
Test Coverage
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
  -->

<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd">
    <description>SCIPIO: New Content Image Services</description>
    <vendor>Ilscipio GmbH</vendor>

    <!-- SCIPIO: WARN: some of these services contain security-sensitive parameters
        and should not be called directly as controller events (assume all except where otherwise noted) -->

    <service name="contentImageFileScaleInAllSizeCore" engine="java"
             location="com.ilscipio.scipio.content.image.ContentImageServices" invoke="contentImageFileScaleInAllSizeCore" auth="false" transaction-timeout="1800">
        <description>Scales a content/generic image file according to size types in ImageProperties.xml - core implementation (caller specifies locations/filenames); also supports component:// and file:// prefixes</description>
        <!-- INPUT IMAGE -->
        <attribute name="imageOrigPath" mode="IN" type="String" optional="true">
            <description>Full path of original image in filesystem as input (alternative to imageOrigUrl; if neither specified, auto-determines an original filename under imageServerPath)</description>
        </attribute>
        <attribute name="imageOrigUrl" mode="IN" type="String" optional="true">
            <description>URL of image relative to server root of original image in filesystem as input; WARN: 2017-07-04: MUST start with imageUrlPrefix else error; no other mount-points supported (alternative to imageOrigPath; if neither specified, auto-determines an original filename under imageServerPath)</description>
        </attribute>
        <attribute name="imageOrigFn" mode="IN" type="String" optional="true">
            <description>Original filename (no directories) of the image - required only if neither imageOrigPath nor imageOrigUrl specified</description>
        </attribute>
        <attribute name="imageOrigFnFmt" mode="IN" type="String" optional="true">
            <description>Image filename format string for original only, relative to imageServerPath/imageUrlPrefix, no extension; only useful if copyOrig==true or if imageOrigPath/imageOrigUrl are omitted (default: same as imageFnFmt)</description>
        </attribute>
        <!-- TODO: support this alternate input
        <attribute name="imageOrigContentId" mode="IN" type="String" optional="true">
            <description>Original image contentId as input (alternative to imageOrigPath)</description>
        </attribute>-->

        <!-- BASE PATHS -->
        <attribute name="imageServerPath" mode="IN" type="String" optional="true">
            <description>Full filesystem path of base server image, parameterized with ${tenantId} (default: uses image.server.path / content.properties); also supports component:// and file:// prefixes</description>
        </attribute>
        <attribute name="imageUrlPrefix" mode="IN" type="String" optional="true">
            <description>URL prefix for generated images, parameterized with ${tenantId} (default: uses image.url.prefix / content.properties)</description>
        </attribute>
        
        <!-- GENERATED FILES PARAMETERS -->
        <attribute name="imageFnFmt" mode="IN" type="String" optional="false">
            <description>Image filename format string, relative to imageServerPath/imageUrlPrefix, no extension, parameterized with ${sizetype} (or ${type}), required</description>
        </attribute>
        <attribute name="imagePathArgs" mode="IN" type="Map" optional="true">
            <description>Additional args for parameterized paths</description>
        </attribute>

        <!-- IMAGE PROFILE -->
        <attribute name="imageProfile" mode="IN" type="Object" optional="true">
            <description>Image profile, now generally required (name or org.ofbiz.common.image.ImageProfile)</description>
        </attribute>
        <attribute name="defaultImageProfile" mode="IN" type="Object" optional="true" default-value="IMAGE_CONTENT">
            <description>Default image profile, for wrapping services (name or org.ofbiz.common.image.ImageProfile)</description>
        </attribute>
        <attribute name="imageVariantConfig" mode="IN" type="org.ofbiz.common.image.ImageVariantConfig" optional="true">
            <description>Image variant config, alternative to imagePropXmlPath</description>
        </attribute>
        <attribute name="imagePropXmlPath" mode="IN" type="String" optional="true">
            <description>Path to ImageProperties.xml file containing size types, from ofbiz home root</description>
        </attribute>
        <attribute mode="IN" name="imageWriteOptions" type="Map" optional="true"/>

        <attribute name="sizeTypeList" mode="IN" type="Collection" optional="true">
            <description>List of size types to generate and return (default: all types in file)</description>
        </attribute>
        <attribute name="copyOrig" mode="IN" type="Boolean" optional="true">
            <description>If true, also creates copy of the original under the size type "original" (default: false)</description>
        </attribute>
        <attribute name="deleteOld" mode="IN" type="Boolean" optional="true">
            <description>[TODO: NOT IMPLEMENTED] If true, also deletes old files in target directory (default: false)</description>
        </attribute>
        
        <!-- SCALING OPTIONS -->
        <attribute name="scalingOptions" mode="IN" type="Map" optional="true">
            <description>Scaling options, notably the entry: scalerName (algorithm or library name)</description>
        </attribute>

        <!-- OUTPUT -->
        <attribute name="imageUrlMap" mode="OUT" type="Map" optional="true">
            <description>Map of size types to URLs (relative to server root, with imageUrlPrefix); if copyOrig==true, also contains "original"</description>
        </attribute>
        <attribute name="imageInfoMap" mode="OUT" type="Map" optional="true">
            <description>Map of maps describing url, width, height and variantInfo for each sizeType; also contains "original" which contains copyOrig boolean (SCIPIO)</description>
        </attribute>
        <attribute name="bufferedImage" mode="OUT" type="java.awt.image.BufferedImage" optional="true">
            <description>Original image contents, for reuse</description>
        </attribute>
        <attribute name="successCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="failCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="skipCount" mode="OUT" type="Integer" optional="true"/><!-- FIXME: currently always zero for this service -->
        <attribute name="reason" mode="OUT" type="String" optional="true">
            <description>Known values: unsupported-colorspace</description>
        </attribute>
    </service>
    
    <service name="contentImageDbScaleInAllSizeCore" engine="java"
             location="com.ilscipio.scipio.content.image.ContentImageServices" invoke="contentImageDbScaleInAllSizeCore" auth="false" transaction-timeout="1800">
        <description>Scales a content/generic database image according to size types in ImageProperties.xml - core implementation (caller specifies all locations/filenames)</description>    
        
        <!-- INPUT IMAGE -->
        <attribute name="imageOrigContentId" mode="IN" type="String" optional="false">
            <description>Original image contentId as input (alternative to imageOrigPath)</description>
        </attribute>
        <attribute name="imageOrigFn" mode="IN" type="String" optional="true">
            <description>Original filename (no directories) to use for the original image; by default tries to get this from DataResource.objectInfo
                NOTE: Only required if the original DataResource.objectInfo did not contain a filename or path to a file (sometimes the case)</description>
        </attribute>
        <!-- TODO?
        <attribute name="imageOrigPath" mode="IN" type="String" optional="true">
            <description>Full path of original image in filesystem as input (alternative to imageOrigContentId)</description>
        </attribute>-->
    
        <!-- GENERATED RECORD PARAMETERS -->
        <attribute name="targetFmtExt" mode="IN" type="String" optional="true">
            <description>Target format name, same as file extension, e.g. png, jpg, ... (default: inferred from original DataResource.mimeTypeId)</description>
        </attribute>

        <!-- IMAGE PROFILE -->
        <attribute name="imageProfile" mode="IN" type="Object" optional="true">
            <description>Image profile, now generally required (name or org.ofbiz.common.image.ImageProfile)</description>
        </attribute>
        <attribute name="defaultImageProfile" mode="IN" type="Object" optional="true" default-value="IMAGE_CONTENT">
            <description>Default image profile, for wrapping services (name or org.ofbiz.common.image.ImageProfile)</description>
        </attribute>
        <attribute name="imageVariantConfig" mode="IN" type="org.ofbiz.common.image.ImageVariantConfig" optional="true">
            <description>Image variant config, alternative to imagePropXmlPath</description>
        </attribute>
        <attribute name="imagePropXmlPath" mode="IN" type="String" optional="true">
            <description>Path to ImageProperties.xml file containing size types, from ofbiz home root</description>
        </attribute>
        <attribute mode="IN" name="imageWriteOptions" type="Map" optional="true"/>

        <attribute name="sizeTypeList" mode="IN" type="Collection" optional="true">
            <description>List of size types to generate and return (default: all types in file)</description>
        </attribute>
        <!-- not supporting this here: I think it will always be a negative
        <attribute name="copyOrig" mode="IN" type="Boolean" optional="true">
            <description>If true, also creates copy of the original under the size type "original" (default: false)</description>
        </attribute>-->
        <attribute name="deleteOld" mode="IN" type="Boolean" optional="true">
            <description>If true, removes all existing related images before creating new ones (default: false)
                2020-11: AVOID USE: recreateExisting should be specified as true instead, which will update records in-place, which is a lot faster
                and more friendly toward frontend behavior.</description>
        </attribute>
        <attribute name="recreateExisting" mode="IN" type="Boolean" optional="true" default-value="false">
            <description>If false (default), existing files for the size types are ignored and not regenerated; if true, all or give size types are always regenerated (slow)</description>
        </attribute>
        <attribute name="createdDate" mode="IN" type="Timestamp" optional="true">
            <description>Optional createdDate for Content and DataResource</description>
        </attribute>
        
        <!-- Content/DataResource  -->
        <attribute name="contentFields" mode="IN" type="Map" optional="true">
            <description>Fields to use to populate the created Content entities (all sizeTypes)
                NOTE: entries can be FlexibleStringExpander instances. defaults: 
                    contentName (default: "${fields.contentName}_${sizetype}")</description>
        </attribute>
        <attribute name="dataResourceFields" mode="IN" type="Map" optional="true">
            <description>Fields to use to populate the created DataResource entities (all sizeTypes)
                NOTE: entries can be FlexibleStringExpander instances. defaults: 
                    dataResourceName (default: "${fields.dataResourceName}_${sizetype}"),
                    objectInfo (default: "${origfn}_${sizetype}.${ext}" NOTE: origfn comes from objectInfo but may be imageOrigFn w/o ext - if passed)</description>
        </attribute>
        <attribute name="contentFieldsMap" mode="IN" type="Map" optional="true">
            <description>Map of fields to use to populate the duplicated original Content entity, if copyOrig true (map key: sizeType)
                NOTE: entries can be FlexibleStringExpander instances (see contentFields)</description>
        </attribute>
        <attribute name="dataResourceFieldsMap" mode="IN" type="Map" optional="true">
            <description>Map of fields to use to populate the duplicated original DataResource entity, if copyOrig true (map key: sizeType)
                NOTE: entries can be FlexibleStringExpander instances (see dataResourceFields)</description>
        </attribute>
        <attribute name="fileSizeDataResAttrName" mode="IN" type="String" optional="true">
            <description>If specified, will add a DataResourceAttribute with this name containing the total filesize</description>
        </attribute>
        
        <!-- ContentAssoc -->
        <attribute name="contentAssocTypeId" mode="IN" type="String" optional="true">
            <description>DEPRECATED: 2020-09: Generally the default is assumed in most circumstances, so setting this to anything else should be avoided.
                Content assoc type, with support for flexible expressions (default: "IMGSZ_${sizetype}")
                NOTE: the entire string is automatically uppercased</description>
        </attribute>
    
        <!-- SCALING OPTIONS -->
        <attribute name="scalingOptions" mode="IN" type="Map" optional="true">
            <description>Scaling options, notably the entry: scalerName (algorithm or library name)</description>
        </attribute>

        <!-- OUTPUT -->
        <attribute name="imageContentIdMap" mode="OUT" type="Map" optional="true">
            <description>Map of size types to image record contentIds</description>
        </attribute>
        <attribute name="bufferedImage" mode="OUT" type="java.awt.image.BufferedImage" optional="true">
            <description>Original image contents, for reuse</description>
        </attribute>
        <attribute name="successCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="failCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="skipCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="reason" mode="OUT" type="String" optional="true">
            <description>Known values: unsupported-colorspace</description>
        </attribute>
    </service>

    <!-- NOTE: For product images, use productImageAutoRescale -->
    <service name="contentImageAutoRescale" engine="java"
             location="com.ilscipio.scipio.content.image.ContentImageServices" invoke="contentImageAutoRescale" auth="false" transaction-timeout="1800">
        <description>Automatically rescales a content image</description>
        <attribute name="contentId" mode="IN" type="String" optional="false"/>
        <attribute name="contentDataResource" mode="IN" type="GenericValue" optional="true">
            <description>Optional ContentDataResourceRequiredView instance matching contentId, if provided (optimization)</description>
        </attribute>
        <attribute name="sizeTypeList" mode="IN" type="Collection" optional="true">
            <description>Optional list of size dimension names to restrict resizing to (e.g.: 320x240, small); unlisted are left unchanged</description>
        </attribute>
        <attribute name="createNew" mode="IN" type="Boolean" optional="true" default-value="true">
            <description>If true, even if the image currently has no variants, attempts to generate new variants;
                if false, only regenerates if variants already created</description>
        </attribute>
        <attribute name="recreateExisting" mode="IN" type="Boolean" optional="true" default-value="false">
            <description>If false (default), existing files for the size types are ignored and not regenerated; if true, all or give size types are always regenerated (slow)</description>
        </attribute>
        <attribute mode="IN" name="deleteOld" type="Boolean" optional="true" default-value="false">
            <description>Not recommended unless corruption: delete the old ContentAssoc/Content/DataResource before creating new ones (old behavior)</description>
        </attribute>
        <attribute name="nonFatal" mode="IN" type="Boolean" optional="true" default-value="false">
            <description>If true, runs in separate transaction and returns failure on image resize fail;
                if false, runs in current transaction and returns error on on image resize fail</description>
        </attribute>
        <attribute name="moment" mode="IN" type="Timestamp" optional="true">
            <description>Specific createdDate for Content and DataResource</description>
        </attribute>
        <attribute name="doLog" mode="IN" type="Boolean" optional="true" default-value="false"/>
        <attribute name="progress" mode="IN" type="String" optional="true"/>
        <attribute name="reason" mode="OUT" type="String" optional="true"/>
        <attribute name="variantSuccessCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="variantFailCount" mode="OUT" type="Integer" optional="true"/>
        <attribute name="variantSkipCount" mode="OUT" type="Integer" optional="true"/>
    </service>

    <service name="contentImageVariantsDistributedClearCaches" engine="jms" location="serviceMessenger" invoke="contentImageVariantsClearCaches"
             auth="true" use-transaction="false" log-eca="quiet" log="quiet" hideResultInLog="true">
        <description>Clear ContentImageVariants caches (SCIPIO)</description>
    </service>
    <service name="contentImageVariantsClearCaches" engine="java" export="true"
             location="com.ilscipio.scipio.content.image.ContentImageVariants" invoke="clearCaches" auth="true" use-transaction="false">
        <description>Clear ContentImageVariants caches (SCIPIO)</description>
        <!--<permission-service service-name="cmsGenericPermission" main-action="UPDATE"/>-->
        <attribute name="distribute" type="Boolean" mode="IN" optional="true" default-value="false"/>
    </service>
</services>