blob: 73f8797f266d22ae3dddbf6b2fda4ae574193f99 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd">
<!-- Methods for DataResource -->
<simple-method method-name="createDataResource" short-description="Create a Data Resource">
<make-value entity-name="DataResource" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<if-empty field="newEntity.dataResourceId">
<sequenced-id sequence-name="DataResource" field="newEntity.dataResourceId"/>
</if-empty>
<now-timestamp field="nowTimestamp"/>
<set field="newEntity.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="newEntity.createdByUserLogin" from-field="userLogin.userLoginId"/>
<set field="newEntity.lastModifiedDate" from-field="nowTimestamp"/>
<set field="newEntity.createdDate" from-field="nowTimestamp"/>
<if-empty field="parameters.dataTemplateTypeId">
<set field="newEntity.dataTemplateTypeId" value="NONE"/>
</if-empty>
<if-empty field="parameters.statusId">
<!-- get the first status item -->
<entity-and entity-name="StatusItem" list="contentStatus">
<field-map field-name="statusTypeId" value="CONTENT_STATUS"/>
<order-by field-name="sequenceId"/>
</entity-and>
<first-from-list entry="statusItem" list="contentStatus"/>
<set field="newEntity.statusId" from-field="statusItem.statusId"/>
</if-empty>
<if-empty field="newEntity.mimeTypeId">
<if-not-empty field="parameters.uploadedFile">
<call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getMimeTypeWithByteBuffer" ret-field="newEntity.mimeTypeId">
<field field="parameters.uploadedFile" type="java.nio.ByteBuffer"/>
</call-class-method>
</if-not-empty>
</if-empty>
<create-value value-field="newEntity"/>
<field-to-result field="newEntity.dataResourceId" result-name="dataResourceId"/>
<field-to-result field="newEntity" result-name="dataResource"/>
</simple-method>
<simple-method method-name="updateDataResource" short-description="Update a Data Resource">
<entity-one entity-name="DataResource" value-field="lookedUpValue"/>
<to-string field="parameters.locale"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<now-timestamp field="nowTimestamp"/>
<set field="lookedUpValue.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="lookedUpValue.lastModifiedDate" from-field="nowTimestamp"/>
<store-value value-field="lookedUpValue"/>
<field-to-result field="parameters.dataResourceId" result-name="dataResourceId"/>
</simple-method>
<simple-method method-name="deleteDataResource" short-description="Delete a Data Resource">
<entity-one entity-name="DataResource" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="createDataResourceAndAssocToContent" short-description="Create a Data Resource and return the data resource type">
<entity-one value-field="content" entity-name="Content"/>
<if-empty field="content">
<add-error>
<fail-property resource="ContentErrorUiLabels" property="layoutEvents.content_empty"/>
</add-error>
<check-errors/>
</if-empty>
<set-service-fields service-name="createDataResource" to-map="dataResourceCtx" map="parameters"/>
<call-service service-name="createDataResource" in-map-name="dataResourceCtx">
<result-to-field result-name="dataResource"/>
</call-service>
<if-compare field="parameters.templateDataResource" operator="equals" value="Y">
<set field="contentCtx.templateDataResourceId" from-field="parameters.dataResourceId" />
<else>
<set field="contentCtx.dataResourceId" from-field="parameters.dataResourceId" />
</else>
</if-compare>
<set field="contentCtx.contentId" from-field="parameters.contentId"/>
<call-service service-name="updateContent" in-map-name="contentCtx"/>
<field-to-result field="parameters.contentId" result-name="contentId"/>
<if-compare field="dataResource.dataResourceTypeId" operator="equals" value="ELECTRONIC_TEXT"><return response-code="${dataResource.dataResourceTypeId}"/></if-compare>
<if-compare field="dataResource.dataResourceTypeId" operator="equals" value="IMAGE_OBJECT"><return response-code="${dataResource.dataResourceTypeId}"/></if-compare>
</simple-method>
<!-- Methods for DataResourceMetaData -->
<simple-method method-name="createDataResourceMetaData" short-description="Create Data Resource Meta Data">
<check-permission permission="CONTENTMGR" action="_CREATE">
<fail-property resource="ContentUiLabels" property="ContentSecurityCreatePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourceMetaData" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateDataResourceMetaData" short-description="Update Data Resource Meta Data">
<check-permission permission="CONTENTMGR" action="_UPDATE">
<fail-property resource="ContentUiLabels" property="ContentSecurityUpdatePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourceMetaData" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceMetaData" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourceMetaData" short-description="Remove Data Resource Meta Data">
<check-permission permission="CONTENTMGR" action="_DELETE">
<fail-property resource="ContentUiLabels" property="ContentSecurityDeletePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourceMetaData" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceMetaData" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataResourcePurpose -->
<simple-method method-name="createDataResourcePurpose" short-description="Create Data Resource Purpose">
<check-permission permission="CONTENTMGR" action="_CREATE">
<fail-property resource="ContentUiLabels" property="ContentSecurityCreatePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourcePurpose" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateDataResourcePurpose" short-description="Update Data Resource Purpose">
<check-permission permission="CONTENTMGR" action="_UPDATE">
<fail-property resource="ContentUiLabels" property="ContentSecurityUpdatePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourcePurpose" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourcePurpose" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourcePurpose" short-description="Remove Data Resource Purpose">
<check-permission permission="CONTENTMGR" action="_DELETE">
<fail-property resource="ContentUiLabels" property="ContentSecurityDeletePermission"/>
</check-permission>
<check-errors/>
<make-value entity-name="DataResourcePurpose" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourcePurpose" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataResourceRole -->
<simple-method method-name="createDataResourceRole" short-description="Create Data Resource Role">
<if-not-empty field="parameters.partyId">
<make-value entity-name="DataResourceRole" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<if-empty field="newEntity.fromDate">
<now-timestamp field="nowTimestamp"/>
<set field="newEntity.fromDate" from-field="nowTimestamp"/>
</if-empty>
<create-value value-field="newEntity"/>
</if-not-empty>
</simple-method>
<simple-method method-name="updateDataResourceRole" short-description="Update Data Resource Role">
<make-value entity-name="DataResourceRole" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceRole" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourceRole" short-description="Remove Data Resource Role">
<make-value entity-name="DataResourceRole" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceRole" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataCategory -->
<simple-method method-name="createDataCategory" short-description="Create Data Category">
<make-value entity-name="DataCategory" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="dataCategoryId" field="newEntity.dataCategoryId"/>
</simple-method>
<simple-method method-name="updateDataCategory" short-description="Update Data Category">
<make-value entity-name="DataCategory" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataCategory" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataCategory" short-description="Remove Data DateCategory">
<make-value entity-name="DataCategory" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataCategory" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataResourceType -->
<simple-method method-name="createDataResourceType" short-description="Create Data Resource Type">
<make-value entity-name="DataResourceType" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="dataResourceTypeId" field="newEntity.dataResourceTypeId"/>
</simple-method>
<simple-method method-name="updateDataResourceType" short-description="Update Data Resource Type">
<make-value entity-name="DataResourceType" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceType" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourceType" short-description="Remove Data Resource Type">
<make-value entity-name="DataResourceType" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceType" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataResourceAttribute -->
<simple-method method-name="createDataResourceAttribute" short-description="Create Data Resource Attribute">
<make-value entity-name="DataResourceAttribute" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateDataResourceAttribute" short-description="Update Data Resource Attribute">
<make-value entity-name="DataResourceAttribute" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceAttribute" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourceAttribute" short-description="Remove Data Resource Attribute">
<make-value entity-name="DataResourceAttribute" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceAttribute" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for DataResourceTypeAttr -->
<simple-method method-name="createDataResourceTypeAttr" short-description="Create Data Resource Type Attribute">
<make-value entity-name="DataResourceTypeAttr" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateDataResourceTypeAttr" short-description="Update Data Resource Type Attribute">
<make-value entity-name="DataResourceTypeAttr" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceTypeAttr" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeDataResourceTypeAttr" short-description="Remove Data Resource Type Attribute">
<make-value entity-name="DataResourceTypeAttr" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="DataResourceTypeAttr" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for CharacterSet -->
<simple-method method-name="createCharacterSet" short-description="Create Character Set">
<make-value entity-name="CharacterSet" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="characterSetId" field="newEntity.characterSetId"/>
</simple-method>
<simple-method method-name="updateCharacterSet" short-description="Update Character Set">
<make-value entity-name="CharacterSet" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="CharacterSet" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeCharacterSet" short-description="Remove Character Set">
<make-value entity-name="CharacterSet" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="CharacterSet" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for FileExtension -->
<simple-method method-name="createFileExtension" short-description="Create Data Resource Role">
<make-value entity-name="FileExtension" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="fileExtensionId" field="newEntity.fileExtensionId"/>
</simple-method>
<simple-method method-name="updateFileExtension" short-description="Update Data Resource Role">
<make-value entity-name="FileExtension" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="FileExtension" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeFileExtension" short-description="Remove Data Resource Role">
<make-value entity-name="FileExtension" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="FileExtension" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for MetaDataPredicate -->
<simple-method method-name="createMetaDataPredicate" short-description="Create Data Resource Role">
<make-value entity-name="MetaDataPredicate" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="metaDataPredicateId" field="newEntity.metaDataPredicateId"/>
</simple-method>
<simple-method method-name="updateMetaDataPredicate" short-description="Update Data Resource Role">
<make-value entity-name="MetaDataPredicate" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MetaDataPredicate" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeMetaDataPredicate" short-description="Remove Data Resource Role">
<make-value entity-name="MetaDataPredicate" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MetaDataPredicate" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for MimeType -->
<simple-method method-name="createMimeType" short-description="Create MimeType">
<make-value entity-name="MimeType" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="mimeTypeId" field="newEntity.mimeTypeId"/>
</simple-method>
<simple-method method-name="updateMimeType" short-description="Update MimeType">
<make-value entity-name="MimeType" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MimeType" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeMimeType" short-description="Remove MimeType">
<make-value entity-name="MimeType" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MimeType" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for MimeTypeHtmlTemplate -->
<simple-method method-name="createMimeTypeHtmlTemplate" short-description="Create MimeTypeHtmlTemplate">
<make-value entity-name="MimeTypeHtmlTemplate" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateMimeTypeHtmlTemplate" short-description="Update MimeTypeHtmlTemplate">
<make-value entity-name="MimeTypeHtmlTemplate" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MimeTypeHtmlTemplate" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeMimeTypeHtmlTemplate" short-description="Remove MimeTypeHtmlTemplate">
<make-value entity-name="MimeTypeHtmlTemplate" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="MimeTypeHtmlTemplate" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for ElectronicText -->
<simple-method method-name="createElectronicText" short-description="Create Electronic Text">
<make-value entity-name="ElectronicText" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result result-name="dataResourceId" field="newEntity.dataResourceId"/>
</simple-method>
<simple-method method-name="updateElectronicText" short-description="Update Electronic Text">
<make-value entity-name="ElectronicText" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="ElectronicText" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
<field-to-result result-name="dataResourceId" field="lookedUpValue.dataResourceId"/>
</simple-method>
<simple-method method-name="removeElectronicText" short-description="Remove Electronic Text">
<make-value entity-name="ElectronicText" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="ElectronicText" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for ImageDataResource -->
<simple-method method-name="createImageDataResource" short-description="Create Image Data Resource">
<make-value entity-name="ImageDataResource" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateImageDataResource" short-description="Update Image Data Resource">
<make-value entity-name="ImageDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="ImageDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeImageDataResource" short-description="Remove Image Data Resource">
<make-value entity-name="ImageDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="ImageDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for VideoDataResource -->
<simple-method method-name="createVideoDataResource" short-description="Create Video Data Resource">
<make-value entity-name="VideoDataResource" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateVideoDataResource" short-description="Update Video Data Resource">
<make-value entity-name="VideoDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="VideoDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeVideoDataResource" short-description="Remove Video Data Resource">
<make-value entity-name="VideoDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="VideoDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for AudioDataResource -->
<simple-method method-name="createAudioDataResource" short-description="Create Audio Data Resource">
<make-value entity-name="AudioDataResource" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateAudioDataResource" short-description="Update Audio Data Resource">
<make-value entity-name="AudioDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="AudioDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeAudioDataResource" short-description="Remove Audio Data Resource">
<make-value entity-name="AudioDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="AudioDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!-- Methods for OtherDataResource -->
<simple-method method-name="createOtherDataResource" short-description="Create Other Data Resource">
<make-value entity-name="OtherDataResource" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<log level="always" message="created new OtherDataResource: ${newEntity}"/>
</simple-method>
<simple-method method-name="updateOtherDataResource" short-description="Update Other Data Resource">
<make-value entity-name="OtherDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="OtherDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="removeOtherDataResource" short-description="Remove Other Data Resource">
<make-value entity-name="OtherDataResource" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="OtherDataResource" map="lookupKeyValue" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<!--
getElectronicText
Passed a Content GenericValue or a contentId, this service returns the text data from
ElectronicText in result.textData.
Not that this service does not now do permission checking.
-->
<simple-method method-name="getElectronicText" short-description="Get Electronic Text" login-required="false">
<set field="userLogin" from-field="parameters.userLogin"/>
<set field="currentContent" from-field="parameters.content"/>
<log level="always" message="GETELECTRONICTEXT, currentContent:${currentContent}"/>
<if-empty field="currentContent">
<if-not-empty field="parameters.contentId">
<entity-one entity-name="Content" value-field="currentContent" use-cache="true"/>
</if-not-empty>
<if-empty field="currentContent">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNeitherContentSupplied"/>
</add-error>
</if-empty>
</if-empty>
<check-errors/>
<if-empty field="currentContent.dataResourceId">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<check-errors/>
<field-to-result field="currentContent.dataResourceId" result-name="dataResourceId"/>
<entity-one entity-name="ElectronicText" value-field="eText">
<field-map field-name="dataResourceId" from-field="currentContent.dataResourceId"/>
</entity-one>
<if-empty field="eText">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentElectronicTextNotFound"/>
</add-error>
</if-empty>
<check-errors/>
<field-to-result field="eText.textData" result-name="textData"/>
<log level="always" message="result:${result}"/>
<log level="always" message="parameters:${parameters}"/>
</simple-method>
<simple-method method-name="attachUploadToDataResource" short-description="Attach an uploaded file to a data resource">
<set field="isUpdate" value="false"/>
<property-to-field resource="content.properties" property="content.upload.always.local.file" field="forceLocal"/>
<if>
<condition>
<and>
<if-compare field="forceLocal" value="true" operator="equals"/>
<not>
<or>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="LOCAL_FILE"/>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="OFBIZ_FILE"/>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="CONTEXT_FILE"/>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="LOCAL_FILE_BIN"/>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="OFBIZ_FILE_BIN"/>
<if-compare field="parameters.dataResourceTypeId" operator="equals" value="CONTEXT_FILE_BIN"/>
</or>
</not>
</and>
</condition>
<then>
<set field="parameters.dataResourceTypeId" value="LOCAL_FILE"/>
</then>
</if>
<if-empty field="parameters.dataResourceTypeId">
<!-- create default behavior -->
<if>
<condition>
<not>
<if-empty field="parameters._uploadedFile_contentType"/>
</not>
</condition>
<then>
<if>
<condition>
<if-regexp field="parameters._uploadedFile_contentType" expr="image.*"/>
</condition>
<then>
<set field="parameters.dataResourceTypeId" value="IMAGE_OBJECT"/>
</then>
<else-if>
<condition>
<if-regexp field="parameters._uploadedFile_contentType" expr="video.*"/>
</condition>
<then>
<set field="parameters.dataResourceTypeId" value="VIDEO_OBJECT"/>
</then>
</else-if>
<else-if>
<condition>
<if-regexp field="parameters._uploadedFile_contentType" expr="audio.*"/>
</condition>
<then>
<set field="parameters.dataResourceTypeId" value="AUDIO_OBJECT"/>
</then>
</else-if>
<else>
<set field="parameters.dataResourceTypeId" value="OTHER_OBJECT"/>
</else>
</if>
</then>
<else>
<set field="parameters.dataResourceTypeId" value="OTHER_OBJECT"/>
</else>
</if>
</if-empty>
<if>
<condition>
<or>
<if-compare field="parameters.dataResourceTypeId" value="LOCAL_FILE" operator="equals"/>
<if-compare field="parameters.dataResourceTypeId" value="LOCAL_FILE_BIN" operator="equals"/>
</or>
</condition>
<then>
<call-simple-method method-name="saveLocalFileDataResource"/>
<return/>
</then>
</if>
<if>
<condition>
<or>
<if-compare field="parameters.dataResourceTypeId" value="OFBIZ_FILE" operator="equals"/>
<if-compare field="parameters.dataResourceTypeId" value="OFBIZ_FILE_BIN" operator="equals"/>
</or>
</condition>
<then>
<call-simple-method method-name="saveOfbizFileDataResource"/>
<return/>
</then>
</if>
<if>
<condition>
<or>
<if-compare field="parameters.dataResourceTypeId" value="CONTEXT_FILE" operator="equals"/>
<if-compare field="parameters.dataResourceTypeId" value="CONTEXT_FILE_BIN" operator="equals"/>
</or>
</condition>
<then>
<call-simple-method method-name="saveContextFileDataResource"/>
<return/>
</then>
</if>
<if-compare field="parameters.dataResourceTypeId" value="IMAGE_OBJECT" operator="equals">
<entity-one entity-name="ImageDataResource" value-field="dataResObj">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-not-empty field="dataResObj">
<set field="isUpdate" value="true"/>
</if-not-empty>
<call-simple-method method-name="saveImageObjectDateResource"/>
<return/>
</if-compare>
<if-compare field="parameters.dataResourceTypeId" value="VIDEO_OBJECT" operator="equals">
<entity-one entity-name="VideoDataResource" value-field="dataResObj">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-not-empty field="dataResObj">
<set field="isUpdate" value="true"/>
</if-not-empty>
<call-simple-method method-name="saveVideoObjectDateResource"/>
<return/>
</if-compare>
<if-compare field="parameters.dataResourceTypeId" value="AUDIO_OBJECT" operator="equals">
<entity-one entity-name="AudioDataResource" value-field="dataResObj">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-not-empty field="dataResObj">
<set field="isUpdate" value="true"/>
</if-not-empty>
<call-simple-method method-name="saveAudioObjectDateResource"/>
<return/>
</if-compare>
<if-compare field="parameters.dataResourceTypeId" value="OTHER_OBJECT" operator="equals">
<entity-one entity-name="OtherDataResource" value-field="dataResObj">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-not-empty field="dataResObj">
<set field="isUpdate" value="true"/>
</if-not-empty>
<call-simple-method method-name="saveOtherObjectDateResource"/>
<return/>
</if-compare>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataTypeNotYetSupported"/>
</add-error>
<check-errors/>
</simple-method>
<!-- save LOCAL_FILE data -->
<simple-method method-name="saveLocalFileDataResource" short-description="Attach an uploaded file to a data resource as LOCAL_FILE">
<entity-one entity-name="DataResource" value-field="dataResource"/>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
<else>
<if-not-empty field="dataResource.objectInfo">
<set field="isUpdate" value="Y"/>
</if-not-empty>
</else>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<set field="absolute" value="true" type="Boolean"/>
<call-class-method method-name="getDataResourceContentUploadPath" class-name="org.ofbiz.content.data.DataResourceWorker" ret-field="uploadPath">
<field field="delegator" type="org.ofbiz.entity.Delegator"/>
<field field="absolute" type="boolean"/>
</call-class-method>
<log level="info" message="[attachLocalFileToDataResource] - Found Subdir : ${uploadPath}"/>
<set from-field="parameters._uploadedFile_contentType" field="extenLookup.mimeTypeId"/>
<find-by-and entity-name="FileExtension" map="extenLookup" list="extensions"/>
<first-from-list entry="extension" list="extensions"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set value="${uploadPath}/${dataResource.dataResourceId}" field="dataResource.objectInfo"/>
<if-not-empty field="extension">
<set value="${uploadPath}/${dataResource.dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>
</if-not-empty>
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<store-value value-field="dataResource"/>
<set-service-fields service-name="createAnonFile" map="dataResource" to-map="fileCtx"/>
<set from-field="parameters.uploadedFile" field="fileCtx.binData"/>
<set from-field="dataResource" field="fileCtx.dataResource"/>
<call-service service-name="createAnonFile" in-map-name="fileCtx" include-user-login="true"/>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save OFBIZ_FILE data -->
<simple-method method-name="saveOfbizFileDataResource" short-description="Attach an uploaded file to a data resource as OFBIZ_FILE">
<entity-one entity-name="DataResource" value-field="dataResource"/>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
<else>
<if-not-empty field="dataResource.objectInfo">
<set field="isUpdate" value="Y"/>
</if-not-empty>
</else>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<set field="absolute" value="false" type="Boolean"/>
<call-class-method method-name="getDataResourceContentUploadPath" class-name="org.ofbiz.content.data.DataResourceWorker" ret-field="uploadPath">
<field field="delegator" type="org.ofbiz.entity.Delegator"/>
<field field="absolute" type="boolean"/>
</call-class-method>
<log level="info" message="[attachLocalFileToDataResource] - Found Subdir : ${uploadPath}"/>
<set from-field="parameters._uploadedFile_contentType" field="extenLookup.mimeTypeId"/>
<find-by-and entity-name="FileExtension" map="extenLookup" list="extensions"/>
<first-from-list entry="extension" list="extensions"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<set value="${uploadPath}/${dataResource.dataResourceId}" field="dataResource.objectInfo"/>
<if-not-empty field="extension">
<set value="${uploadPath}/${dataResource.dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>
</if-not-empty>
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<store-value value-field="dataResource"/>
<set-service-fields service-name="createAnonFile" map="dataResource" to-map="fileCtx"/>
<set from-field="parameters.uploadedFile" field="fileCtx.binData"/>
<set from-field="dataResource" field="fileCtx.dataResource"/>
<call-service service-name="createAnonFile" in-map-name="fileCtx" include-user-login="true"/>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save OTHER_OBJECT data -->
<simple-method method-name="saveOtherObjectDateResource" short-description="Attach an uploaded file to a data resource as OTHER_OBJECT">
<entity-one entity-name="DataResource" value-field="dataResource">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<!-- update the data resource with file data -->
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<store-value value-field="dataResource"/>
<!-- fields serviceName and fileField are required to be set by calling method -->
<set-service-fields service-name="createOtherDataResource" map="dataResource" to-map="serviceContext"/>
<set from-field="parameters.uploadedFile" field="serviceContext.dataResourceContent"/>
<if-compare field="isUpdate" value="true" operator="equals">
<call-service service-name="updateOtherDataResource" in-map-name="serviceContext"/>
<else>
<call-service service-name="createOtherDataResource" in-map-name="serviceContext"/>
</else>
</if-compare>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save IMAGE_OBJECT data -->
<simple-method method-name="saveImageObjectDateResource" short-description="Attach an uploaded file to a data resource as IMAGE_OBJECT">
<entity-one entity-name="DataResource" value-field="dataResource">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<!-- update the data resource with file data -->
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<store-value value-field="dataResource"/>
<!-- fields serviceName and fileField are required to be set by calling method -->
<set-service-fields service-name="createImageDataResource" map="dataResource" to-map="serviceContext"/>
<set from-field="parameters.uploadedFile" field="serviceContext.imageData"/>
<if-compare field="isUpdate" value="true" operator="equals">
<call-service service-name="updateImageDataResource" in-map-name="serviceContext"/>
<else>
<call-service service-name="createImageDataResource" in-map-name="serviceContext"/>
</else>
</if-compare>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save VIDEO_OBJECT data -->
<simple-method method-name="saveVideoObjectDateResource" short-description="Attach an uploaded file to a data resource as VIDEO_OBJECT">
<entity-one entity-name="DataResource" value-field="dataResource">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<!-- update the data resource with file data -->
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<store-value value-field="dataResource"/>
<!-- fields serviceName and fileField are required to be set by calling method -->
<set-service-fields service-name="createVideoDataResource" map="dataResource" to-map="serviceContext"/>
<set from-field="parameters.uploadedFile" field="serviceContext.videoData"/>
<if-compare field="isUpdate" value="true" operator="equals">
<call-service service-name="updateVideoDataResource" in-map-name="serviceContext"/>
<else>
<call-service service-name="createVideoDataResource" in-map-name="serviceContext"/>
</else>
</if-compare>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save AUDIO_OBJECT data -->
<simple-method method-name="saveAudioObjectDateResource" short-description="Attach an uploaded file to a data resource as AUDIO_OBJECT">
<entity-one entity-name="DataResource" value-field="dataResource">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<!-- update the data resource with file data -->
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<store-value value-field="dataResource"/>
<!-- fields serviceName and fileField are required to be set by calling method -->
<set-service-fields service-name="createAudioDataResource" map="dataResource" to-map="serviceContext"/>
<set from-field="parameters.uploadedFile" field="serviceContext.audioData"/>
<if-compare field="isUpdate" value="true" operator="equals">
<call-service service-name="updateAudioDataResource" in-map-name="serviceContext"/>
<else>
<call-service service-name="createAudioDataResource" in-map-name="serviceContext"/>
</else>
</if-compare>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
<!-- save CONTEXT_FILE data -->
<simple-method method-name="saveContextFileDataResource" short-description="Attach an uploaded file to a data resource as CONTEXT_FILE">
<entity-one entity-name="DataResource" value-field="dataResource"/>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
<else>
<if-not-empty field="dataResource.objectInfo">
<set field="isUpdate" value="Y"/>
</if-not-empty>
</else>
</if-empty>
<if>
<condition>
<if-empty field="parameters._uploadedFile_fileName"/>
</condition>
<then>
<if>
<condition>
<or>
<if-empty field="isUpdate"/>
<if-compare field="isUpdate" value="Y" operator="not-equals"/>
</or>
</condition>
<then>
<add-error>
<fail-property resource="ContentUiLabels" property="ContentNoUploadedContentFound"/>
</add-error>
</then>
<else>
<!-- if not upload is found on an update; its okay, don't do anything just return -->
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
<return/>
</else>
</if>
</then>
</if>
<check-errors/>
<set field="uploadPath" from-field="parameters.rootDir"/>
<log level="info" message="[attachLocalFileToDataResource] - Found Subdir : ${uploadPath}"/>
<if-empty field="uploadPath">
<add-error>
<fail-property resource="ContentErrorUiLabels" property="uploadContentAndImage.noRootDirProvided"/>
</add-error>
<check-errors/>
</if-empty>
<log level="info" message="[attachLocalFileToDataResource] - Found Subdir : ${uploadPath}"/>
<set from-field="parameters._uploadedFile_contentType" field="extenLookup.mimeTypeId"/>
<find-by-and entity-name="FileExtension" map="extenLookup" list="extensions"/>
<first-from-list entry="extension" list="extensions"/>
<set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
<set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
<set value="${uploadPath}/${dataResource.dataResourceId}" field="dataResource.objectInfo"/>
<if-not-empty field="extension">
<set value="${uploadPath}/${dataResource.dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>
</if-not-empty>
<set from-field="parameters.dataResourceTypeId" field="dataResource.dataResourceTypeId"/>
<store-value value-field="dataResource"/>
<set-service-fields service-name="createAnonFile" map="dataResource" to-map="fileCtx"/>
<set from-field="parameters.uploadedFile" field="fileCtx.binData"/>
<set from-field="dataResource" field="fileCtx.dataResource"/>
<call-service service-name="createAnonFile" in-map-name="fileCtx" include-user-login="true"/>
<field-to-result result-name="dataResourceId" field="dataResource.dataResourceId"/>
<field-to-result result-name="mimeTypeId" field="dataResource.mimeTypeId"/>
</simple-method>
</simple-methods>