<!--
  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="https://ofbiz.apache.org/dtds/services.xsd">
    <description>Content Component Data Services</description>
    <vendor>OFBiz</vendor>

    <!-- DataResource services -->
    <service name="createDataResource" default-entity-name="DataResource" engine="groovy"
            location="component://content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy" invoke="createDataResource" auth="true">
        <description>Create a DataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="dataResourceId" type="String" mode="INOUT" optional="true"/>
        <attribute name="targetOperationList" type="List" mode="IN" optional="true"/>
        <attribute name="contentPurposeList" type="List" mode="IN" optional="true"/>
        <attribute name="skipPermissionCheck" type="String" mode="IN" optional="true"/>
        <attribute name="roleTypeId" type="String" mode="IN" optional="true"/>
        <attribute name="partyId" type="String" mode="IN" optional="true"/>
        <attribute name="dataResourceId" type="String" mode="OUT" optional="false"/>
        <attribute name="dataResource" type="org.apache.ofbiz.entity.GenericValue" mode="OUT" optional="true"/>
        <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="true"/>
        <override name="objectInfo" allow-html="safe"/>
        <override name="dataResourceName" allow-html="safe"/>
    </service>
    <service name="createDataResourceAndAssocToContent" default-entity-name="DataResource" engine="groovy"
            location="component://content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy" invoke="createDataResourceAndAssocToContent" auth="true">
        <description>Create a DataResource and link this data to the content present</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <implements service="createDataResource" optional="true"/>
        <attribute name="contentId" type="String" mode="INOUT" optional="false">
            <type-validate>
                <fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingContentId"/>
            </type-validate>
        </attribute>
        <attribute name="templateDataResource" type="String" mode="IN" optional="true"/>
    </service>
    <service name="updateDataResource" engine="entity-auto" default-entity-name="DataResource" auth="true" invoke="update">
        <description>Update a DataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="dataResourceId" type="String" mode="IN" optional="false">
            <type-validate>
                <fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingDataResourceId"/>
            </type-validate>
        </attribute>
        <override name="objectInfo" allow-html="safe"/>
        <override name="dataResourceName" allow-html="safe"/>
    </service>
    <service name="removeDataResource" engine="entity-auto" default-entity-name="DataResource" auth="true" invoke="delete">
        <description>Remove DataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <attribute name="targetOperationList" type="List" mode="IN" optional="true"/>
        <attribute name="contentPurposeList" type="List" mode="IN" optional="true"/>
        <attribute name="skipPermissionCheck" type="String" mode="IN" optional="true"/>
    </service>

    <!-- generic create data text service; looks at the type id to determine if ELECTRONIC_TEXT is necessary -->
    <service name="createDataText" engine="route" auth="true">
        <description>Uses ECA to decide if we should call createElectronicText or just createDataResource (SHORT_TEXT)</description>
        <implements service="createDataResource"/>
        <implements service="createElectronicText"/>
    </service>
    <service name="updateDataText" engine="route" auth="true">
        <description>Uses ECA to decide if we should call updateElectronicText or just updateDataResource (SHORT_TEXT)</description>
        <implements service="updateDataResource"/>
        <implements service="updateElectronicText"/>
    </service>

    <!-- these should be deprecated in favor of the ECA style triggers on the base service -->
    <service name="createDataResourceAndText" engine="java" default-entity-name="DataResource" auth="true"
            location="org.apache.ofbiz.content.data.DataServices" invoke="createDataResourceAndText">
        <description>Create a DataResource and, possibly, ElectronicText or ImageDataResource</description>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="textData" mode="IN" optional="true" type="String" allow-html="safe"/>
        <attribute name="targetOperationList" type="List" mode="IN" optional="true"/>
        <attribute name="contentPurposeList" type="List" mode="IN" optional="true"/>
        <attribute name="skipPermissionCheck" type="String" mode="IN" optional="true"/>
    </service>
    <service name="updateDataResourceAndText" engine="java" default-entity-name="DataResource" auth="true"
            location="org.apache.ofbiz.content.data.DataServices" invoke="updateDataResourceAndText">
        <description>Create a DataResource and, possibly, ElectronicText or ImageDataResource</description>
        <auto-attributes include="pk" mode="IN" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="textData" mode="IN" type="String" optional="true"  allow-html="safe"/>
        <attribute name="targetOperationList" type="List" mode="IN" optional="true"/>
        <attribute name="contentPurposeList" type="List" mode="IN" optional="true"/>
        <attribute name="skipPermissionCheck" type="String" mode="IN" optional="true"/>
    </service>

    <!-- ElectronicText services -->
    <service name="createElectronicText" default-entity-name="ElectronicText" engine="entity-auto" invoke="create" auth="true">
        <description>Create a ElectronicText</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <implements service="createDataResource"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="dataResourceTypeId" default-value="ELECTRONIC_TEXT"/>
        <override name="textData" allow-html="safe"/>
    </service>
    <service name="updateElectronicText" default-entity-name="ElectronicText" engine="entity-auto" invoke="update" auth="true">
        <description>Update a ElectronicText</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="contentId" mode="INOUT" optional="true" type="String"/><!-- to optionaly know where this text is belonging to -->
        <override name="textData" allow-html="safe"/>
    </service>
    <service name="createElectronicTextForm" default-entity-name="ElectronicText" engine="entity-auto" invoke="create" auth="true">
        <description>Create a ElectronicText with Form code</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <implements service="createDataResource"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="dataResourceTypeId" default-value="ELECTRONIC_TEXT"/>
        <override name="textData" allow-html="any"/>
    </service>
    <service name="updateElectronicTextForm" default-entity-name="ElectronicText" engine="entity-auto" invoke="update" auth="true">
        <description>Update a ElectronicText with Form code</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <attribute name="contentId" mode="INOUT" optional="true" type="String"/><!-- to optionally know where this text is belonging to -->
        <override name="textData" allow-html="any"/>
    </service>
    <service name="removeElectronicText" default-entity-name="ElectronicText" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove ElectronicText</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>
    <service name="getElectronicText" engine="groovy"
            location="component://content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy" invoke="getElectronicText" default-entity-name="ElectronicText" auth="false" >
        <description>Get a ElectronicText: Can pass either content value object or contentId</description>
        <attribute mode="IN" name="contentId" optional="true" type="String"/>
        <attribute mode="IN" name="content" optional="true" type="org.apache.ofbiz.entity.GenericValue"/>
        <attribute mode="OUT" name="dataResourceId" optional="true" type="String"/>
        <attribute mode="OUT" name="textData" optional="false" type="String"/>
    </service>

    <!-- Image Data Resource services -->
    <service name="createImageDataResource" engine="entity-auto" default-entity-name="ImageDataResource" auth="true" invoke="create">
        <description>Create an ImageDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateImageDataResource" engine="entity-auto" default-entity-name="ImageDataResource" auth="true" invoke="update">
        <description>Update an ImageDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeImageDataResource" engine="entity-auto" default-entity-name="ImageDataResource" auth="true" invoke="delete">
        <description>Remove an ImageDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- Video Data Resource services -->
    <service name="createVideoDataResource" engine="entity-auto" default-entity-name="VideoDataResource" auth="true" invoke="create">
        <description>Create a VideoDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateVideoDataResource" engine="entity-auto" default-entity-name="VideoDataResource" auth="true" invoke="update">
        <description>Update an VideoDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeVideoDataResource" engine="entity-auto" default-entity-name="VideoDataResource" auth="true" invoke="delete">
        <description>Remove an VideoDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- Audio Data Resource services -->
    <service name="createAudioDataResource" engine="entity-auto" default-entity-name="AudioDataResource" auth="true" invoke="create">
        <description>Create an AudioDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAudioDataResource" engine="entity-auto" default-entity-name="AudioDataResource" auth="true" invoke="update">
        <description>Update an AudioDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAudioDataResource" engine="entity-auto" default-entity-name="AudioDataResource" auth="true" invoke="delete">
        <description>Remove an AudioDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- Other Data Resource services -->
    <service name="createOtherDataResource" engine="entity-auto" default-entity-name="OtherDataResource" auth="true" invoke="create">
        <description>Create an OtherDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateOtherDataResource" engine="entity-auto" default-entity-name="OtherDataResource" auth="true" invoke="update">
        <description>Update an OtherDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeOtherDataResource" engine="entity-auto" default-entity-name="OtherDataResource" auth="true" invoke="delete">
        <description>Remove an OtherDataResource</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- Data Resource Meta Services -->
    <service name="createDataResourceMetaData" engine="entity-auto" default-entity-name="DataResourceMetaData" auth="true" invoke="create">
        <description>Create an DataResourceMetaData</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateDataResourceMetaData" engine="entity-auto" default-entity-name="DataResourceMetaData" auth="true" invoke="update">
        <description>Update an DataResourceMetaData</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeDataResourceMetaData" engine="entity-auto" default-entity-name="DataResourceMetaData" auth="true" invoke="delete">
        <description>Remove an DataResourceMetaData</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- Data Resource Purpose Services -->
    <service name="createDataResourcePurpose" engine="entity-auto" default-entity-name="DataResourcePurpose" auth="true" invoke="create">
        <description>Create an DataResourcePurpose</description>
        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateDataResourcePurpose" engine="entity-auto" default-entity-name="DataResourcePurpose" auth="true" invoke="update">
        <description>Update an DataResourcePurpose</description>
        <permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeDataResourcePurpose" engine="entity-auto" default-entity-name="DataResourcePurpose" auth="true" invoke="delete">
        <description>Remove an DataResourcePurpose</description>
        <permission-service service-name="genericDataResourcePermission" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- File services -->
    <service name="createFile" engine="java"
            location="org.apache.ofbiz.content.data.DataServices" invoke="createFile" auth="true">
        <description>Create a File</description>
        <implements service="createDataResource"/>
        <attribute mode="IN" name="dataResource" optional="true" type="org.apache.ofbiz.entity.GenericValue"/>
        <attribute mode="IN" name="binData" optional="true" type="java.nio.ByteBuffer"/>
        <attribute mode="IN" name="textData" optional="true" type="String"/>
        <attribute mode="IN" name="rootDir" optional="true" type="String"/>
        <attribute mode="IN" name="dataResourceTypeId" optional="true" type="String"/>
        <attribute mode="IN" name="objectInfo" optional="true" type="String"/>
    </service>
    <service name="createAnonFile" engine="java"
            location="org.apache.ofbiz.content.data.DataServices" invoke="createFileNoPerm" auth="false">
        <description>Create a File No Permission Required</description>
        <implements service="createFile"/>
    </service>
    <service name="updateFile" engine="java"
            location="org.apache.ofbiz.content.data.DataServices" invoke="updateFile" auth="true">
        <description>Update a File</description>
        <attribute mode="IN" name="dataResource" optional="true" type="org.apache.ofbiz.entity.GenericValue"/>
        <attribute mode="IN" name="binData" optional="true" type="java.nio.ByteBuffer"/>
        <attribute mode="IN" name="textData" optional="true" type="String"/>
        <attribute mode="IN" name="rootDir" optional="true" type="String"/>
        <attribute mode="IN" name="dataResourceTypeId" optional="true" type="String"/>
        <attribute mode="IN" name="objectInfo" optional="true" type="String"/>
    </service>
    <!-- Cleared associated DataResource rendered cache from UtilCache. -->
    <service name="clearAssociatedRenderCache" engine="java" auth="true" default-entity-name="DataResource"
            location="org.apache.ofbiz.content.data.DataServices" invoke="clearAssociatedRenderCache">
        <auto-attributes include="pk" mode="IN" />
    </service>
    
    <service name="createDataTemplateType" engine="entity-auto" invoke="create" default-entity-name="DataTemplateType" auth="true">
        <description>Create a Data Template Type</description>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateDataTemplateType" engine="entity-auto" invoke="update" default-entity-name="DataTemplateType" auth="true">
        <description>Update a Data Template Type</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteDataTemplateType" engine="entity-auto" invoke="delete" default-entity-name="DataTemplateType" auth="true">
        <description>Delete a Data Template Type</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

</services>
