blob: 69cb36b2e2992892a54d8ef2eebe8d689c83c2c0 [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"
xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="createContentAndPurpose" short-description="Create Content And Purpose" login-required="false">
<make-value entity-name="Content" value-field="currentContent"/>
<set-pk-fields map="parameters" value-field="currentContent"/>
<set-nonpk-fields map="parameters" value-field="currentContent"/>
<if-empty field="currentContent.contentId">
<make-next-seq-id seq-field-name="contentId" value-field="currentContent"/>
<sequenced-id field="id" sequence-name="Content"/>
<set field="currentContent.contentId" from-field="id"/>
</if-empty>
<log level="always" message="currentContent: ${currentContent}"/>
<field-to-list field="parameters.contentPurposeTypeId" list="contentPurposeList"/>
<string-to-list list="targetOperationList" string="CONTENT_CREATE"/>
<set field="context.currentContent" from-field="currentContent"/>
<set field="context.contentPurposeList" from-field="contentPurposeList"/>
<set field="context.targetOperationList" from-field="targetOperationList"/>
<set field="context.currentContent" from-field="currentContent"/>
<session-to-field field="context.userLogin" session-name="userLogin"/>
<call-service in-map-name="context" service-name="checkContentPermission">
<result-to-field result-name="permissionStatus" field="permissionStatus"/>
</call-service>
<log level="always" message="permissionStatus:${permissionStatus}"/>
<if-compare field="permissionStatus" operator="not-equals" type="String" value="granted">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentPermissionNotGranted"/>
</add-error>
</if-compare>
<check-errors/>
<if-compare field="permissionStatus" operator="equals" type="String" value="granted">
<create-value value-field="currentContent"/>
<if-not-empty field="parameters.contentPurposeTypeId">
<make-value entity-name="ContentPurpose" value-field="newContentPurpose"/>
<set field="newContentPurpose.contentPurposeTypeId" from-field="parameters.contentPurposeTypeId"/>
<set field="newContentPurpose.contentId" from-field="currentContent.contentId"/>
<create-value value-field="newContentPurpose"/>
</if-not-empty>
</if-compare>
</simple-method>
</simple-methods>