Foren

Kaleo Single Approver Workflow: direct publish

Luca Lupo, geändert vor 11 Jahren.

Kaleo Single Approver Workflow: direct publish

Regular Member Beiträge: 106 Beitrittsdatum: 01.10.12 Neueste Beiträge
Is it possible to say to Kaleo to Publish directly if the web content is created by a specific role?

I mean, the Admin right now can create content (that will be in status pending) and then he can approve the content. What I want is to have two roles:

1. Publisher (users who can create contents but not to approve them). So when a user creates a content it will be in pending status;
2. Approver (users who can approve the contents). They approve the contents, but in the case they create contents, such contents are automatically published as approved.

Any hint?
thumbnail
Christoph Rabel, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

Liferay Legend Beiträge: 1554 Beitrittsdatum: 24.09.09 Neueste Beiträge
Yes.
Change Single Approver Workflow and add a condition:


        <state>
                <name>created</name>
                <initial>true</initial>
                <transitions>
                        <transition>
                                <name>Determine Review</name>
                                <target>review-or-approve</target>
                                <default>true</default>
                        </transition>
                </transitions>
        </state>

        <condition>
                <name>review-or-approve</name>
                <script> <![CDATA[
                                import com.liferay.portal.service.RoleLocalServiceUtil;
                                import com.liferay.portal.kernel.util.GetterUtil;
                                import com.liferay.portal.kernel.workflow.WorkflowConstants;

                                try {
                                        returnValue = "Review";
                                        long userid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
                                        long companyid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
                                        String[] roles={"Approver","Administrator"};
                                        if (RoleLocalServiceUtil.hasUserRoles(userid, companyid, roles, true)) returnValue = "Approved";
                                } catch (Exception e) {
                                  e.printStackTrace();
                                }
                        ]]> </script>
                <script-language>beanshell</script-language>
                <transitions>
                        <transition>
                                <name>Review</name>
                                <target>review</target>
                                <default>false</default>
                        </transition>
                        <transition>
                                <name>Approved</name>
                                <target>approved</target>
                                <default>false</default>
                        </transition>
                </transitions>
        </condition>
Luca Lupo, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

Regular Member Beiträge: 106 Beitrittsdatum: 01.10.12 Neueste Beiträge
Is it enough to change the xml inside the kaleo-web present in webapp folder of tomcat?

If so, I have this...but it seems that nothing happens emoticon



<!--?xml version="1.0"?-->


<workflow-definition xmlns="urn:liferay.com:liferay-workflow_6.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd">
	<name>Single Approver</name>
	<description>A single approver can approve a workflow content.</description>
	<version>1</version>

	 <state>
            <name>created</name>
            <initial>true</initial>
            <transitions>
                <transition>
            		<name>Determine Review</name>
                	<target>review-or-approve</target>
                	<default>true</default>
            	</transition>
            </transitions>
    </state>
    <condition>
		<name>review-or-approve</name>
		<script> <![CDATA[
						import com.liferay.portal.service.RoleLocalServiceUtil;
						import com.liferay.portal.kernel.util.GetterUtil;
						import com.liferay.portal.kernel.workflow.WorkflowConstants;

						try {
								returnValue = "Review";
								long userid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
								long companyid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
								String[] roles={"Approver","Administrator"};
								if (RoleLocalServiceUtil.hasUserRoles(userid, companyid, roles, true)) returnValue = "Approved";
						} catch (Exception e) {
						  e.printStackTrace();
						}
				]]> </script>
		<script-language>beanshell</script-language>
		<transitions>
				<transition>
						<name>Review</name>
						<target>review</target>
						<default>false</default>
				</transition>
				<transition>
						<name>Approved</name>
						<target>approved</target>
						<default>false</default>
				</transition>
		</transitions>
    </condition>
	<task>
		<name>update</name>
		<metadata>
			{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}
		</metadata>
		<actions>
			<action>
				<name>reject</name>
				<script>
					<![CDATA[
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), workflowContext);
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"), workflowContext);
					]]>
				</script>
				<script-language>javascript</script-language>
				<execution-type>onAssignment</execution-type>
			</action>
			<notification>
				<name>Creator Modification Notification</name>
				<template>Your submission was rejected by a reviewer, please modify and resubmit.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
		</actions>
		<assignments>
			<user />
		</assignments>
		<transitions>
			<transition>
				<name>resubmit</name>
				<target>review</target>
			</transition>
		</transitions>
	</task>
	<task>
		<name>review</name>
		<metadata>
			{"xy":[168,36]}
		</metadata>
		<actions>
			<notification>
				<name>Review Notification</name>
				<template>You have a new submission waiting for your review in the workflow.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
			<notification>
				<name>Review Completion Notification</name>
				<template>
					Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
				<template-language>freemarker</template-language>
				<notification-type>email</notification-type>
				<recipients>
					<user />
				</recipients>
				<execution-type>onExit</execution-type>
			</notification>
		</actions>
		<assignments>
			<roles>
				<role>
					<role-type>organization</role-type>
					<name>Organization Administrator</name>
				</role>
				<role>
					<role-type>organization</role-type>
					<name>Organization Content Reviewer</name>
				</role>
				<role>
					<role-type>organization</role-type>
					<name>Organization Owner</name>
				</role>
				<role>
					<role-type>regular</role-type>
					<name>Administrator</name>
				</role>
				<role>
					<role-type>regular</role-type>
					<name>Portal Content Reviewer</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Administrator</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Content Reviewer</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Owner</name>
				</role>
			</roles>
		</assignments>
		<transitions>
			<transition>
				<name>approve</name>
				<target>approved</target>
			</transition>
			<transition>
				<name>reject</name>
				<target>update</target>
				<default>false</default>
			</transition>
		</transitions>
	</task>
	<state>
		<name>approved</name>
		<metadata>
			
				{"xy":[380,51]}
			
		</metadata>
		<actions>
			<action>
				<name>approve</name>
				<script>
					<![CDATA[
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);
					]]>
				</script>
				<script-language>javascript</script-language>
				<execution-type>onEntry</execution-type>
			</action>
		</actions>
	</state>
</workflow-definition>
Luca Lupo, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

Regular Member Beiträge: 106 Beitrittsdatum: 01.10.12 Neueste Beiträge
Thanks, that worked emoticon

Now I'm trying to understand the sending email. I know that Kaleo sends emails when a new content is created, when the content is assigned to someone, and when it is rejected or approved. And I suppose that when the content is assigned to someone, the email arrives to this "someone", but in the other two cases I dunno who will be the receiver.
thumbnail
Harish Kumar, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

Expert Beiträge: 483 Beitrittsdatum: 31.07.10 Neueste Beiträge
Content creator will get the mail in case of approval/rejection.
thumbnail
Jacques Traore, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

Junior Member Beiträge: 49 Beitrittsdatum: 21.01.13 Neueste Beiträge
Luca Lupo:
Thanks, that worked emoticon

Now I'm trying to understand the sending email. I know that Kaleo sends emails when a new content is created, when the content is assigned to someone, and when it is rejected or approved. And I suppose that when the content is assigned to someone, the email arrives to this "someone", but in the other two cases I dunno who will be the receiver.



Hi Lucas,
Was it (finally) enough for you changing directly ..\tomcat-7.0.27\webapps\kaleo-web\WEB-INF\classes\META-INF\definitions\single-approver-definition.xml ?
Because I did the same and it doesn't seem to work.

Thanks by advance.
Vika Tory, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

New Member Beitrag: 1 Beitrittsdatum: 30.10.12 Neueste Beiträge
Hi,

I need to have role (Administrator) which can create contents and these contents are automatically published as approved.
I've tried to use xml that Christoph gave but it still does't work for me. Does anybody know what can be the problem?

Thanks emoticon
thumbnail
Lukas Kornprobst, geändert vor 11 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

New Member Beitrag: 1 Beitrittsdatum: 12.04.12 Neueste Beiträge
Hi,

What is the type of your role? (Site Role, Regular Role, etc.)

Christpoh Condition script is an verry good approach (thx for that emoticon ), but it worked for me only with "Regular Roles", not with "Site Roles" (Liferay v6.1).
So i changed the script in the condition tag with the following:


            <script><![CDATA[import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;


try {
	returnValue = "review";
	long userId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
	long groupId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
	String role = "Approver";
	
	if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(userId, groupId, role, true)) returnValue = "approved";
} catch (Exception e) {
	e.printStackTrace(); 
}
]]></script>

After the change, everything went without any problems with Site Roles for me.
The variable "role" must be changed with your "Site Role" (Administrator).
thumbnail
Ashish Agarwal, geändert vor 8 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

New Member Beiträge: 13 Beitrittsdatum: 07.07.15 Neueste Beiträge
Hi Christoph,

I have tried your xml changes. The workflow is getting approved perfectly due to the code but the asset which is added has the status "Pending Approval" even if the workflow is approved.

Could you let me know what maybe the problem here?
thumbnail
Ashish Agarwal, geändert vor 8 Jahren.

RE: Kaleo Single Approver Workflow: direct publish

New Member Beiträge: 13 Beitrittsdatum: 07.07.15 Neueste Beiträge
Found the root cause of my issue.

It was a synchronization issue between the portal and DB.