Author: sshyrkov
Date: Mon Sep 24 13:48:36 2007
New Revision: 18626

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18626&repname=
=3Djahia
Log:
JAHIA-2282: Sp3: Workflows: Problems with notifying only one lang in order =
to continue to update the other langs in staging + Nstep quick edit mode im=
possible to use if another lang is under approval =

http://www.jahia.net/jira/browse/JAHIA-2282
Resolution: N-Step Workflow - "Quick correction"/"Finish correction" action=
s are now applied on all languages of the content object

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/workflow/nstep/NSt=
epWorkflow.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/workflow/nst=
ep/NStepWorkflow.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/workflow/nstep/NStepWorkflow.java&rev=3D186=
26&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/workflow/nstep/NSt=
epWorkflow.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/workflow/nstep/NSt=
epWorkflow.java Mon Sep 24 13:48:36 2007
@@ -572,7 +572,7 @@
             boolean isStartStep =3D false;
             boolean isFinished =3D false;
             WorkflowInstance instance;
-                        if (ROLLBACK_ACTION_NAME.equals(unTrimmedActionNam=
e)) {
+            if (ROLLBACK_ACTION_NAME.equals(unTrimmedActionName)) {
                 isStartStep =3D instanceManager.rollbackWorkflow(jParams.g=
etUser().getUsername(), objectKey,
                         languageCode);
                 if (isStartStep) {
@@ -602,24 +602,72 @@
                         jParams.getUser().getUsername(),
                         processName, ROLLBACK_AUTHOR_ACTION_NAME, objectKe=
y, languageCode,
                                                                comment);
-                        } else if (UNLOCK_ACTION_NAME.equals(unTrimmedActi=
onName)) {
-                            changeStatus(languageCode, jParams, objectKey,=
 processName,
-                                    EntryLoadRequest.STAGING_WORKFLOW_STAT=
E);
-                            instance =3D instanceManager.getWorkflowInstan=
ceByObjectKey(objectKey, languageCode);
-                            historyManager.saveWorkflowHistory(ServicesReg=
istry.getInstance().getJahiaUserManagerService().lookupUser(
-                                    instance.getAuthorEmail()).getUsername=
(),
-                                                               jParams.get=
User().getUsername(),
-                                                               processName=
, UNLOCK_ACTION_NAME, objectKey, languageCode,
-                                                               comment);
-                        } else if (LOCK_ACTION_NAME.equals(unTrimmedAction=
Name)) {
-                            changeStatus(languageCode, jParams, objectKey,=
 processName,
-                                    EntryLoadRequest.WAITING_WORKFLOW_STAT=
E);
-                            instance =3D instanceManager.getWorkflowInstan=
ceByObjectKey(objectKey, languageCode);
-                            historyManager.saveWorkflowHistory(ServicesReg=
istry.getInstance().getJahiaUserManagerService().lookupUser(
-                                    instance.getAuthorEmail()).getUsername=
(),
-                                                               jParams.get=
User().getUsername(),
-                                                               processName=
, LOCK_ACTION_NAME, objectKey, languageCode,
-                        comment);
+            } else if (UNLOCK_ACTION_NAME.equals(unTrimmedActionName)) {
+                List langs =3D jParams.getSite().getLanguageSettingsAsLoca=
les(
+                        true);
+                // we will unlock all languages
+                for (Iterator iterator =3D langs.iterator(); iterator.hasN=
ext();) {
+                    Locale locale =3D (Locale) iterator.next();
+                    try {
+                        instance =3D instanceManager
+                                .getWorkflowInstanceByObjectKey(objectKey,
+                                        locale.getLanguage());
+                    } catch (ObjectRetrievalFailureException ex) {
+                        continue;
+                    }
+                    final List steps =3D instance.getWorkflow().getSteps();
+                    int startIndex =3D steps.indexOf(instance.getStep()) +=
 1;
+                    // skip if this instance is on the first step
+                    if (startIndex =3D=3D 1) {
+                        continue;
+                    }
+                    changeStatus(locale.getLanguage(), jParams, objectKey,
+                            processName,
+                            EntryLoadRequest.STAGING_WORKFLOW_STATE);
+                    historyManager.saveWorkflowHistory(ServicesRegistry
+                            .getInstance().getJahiaUserManagerService()
+                            .lookupUser(instance.getAuthorEmail())
+                            .getUsername(), jParams.getUser().getUsername(=
),
+                            processName, UNLOCK_ACTION_NAME, objectKey, lo=
cale
+                                    .getLanguage(), comment);
+                    addActionToMailQueue(jParams, actionName, objectKey, l=
ocale
+                            .getLanguage(), comment, isStartStep, false,
+                            instance, userNotifData);
+                }
+                instance =3D null;
+            } else if (LOCK_ACTION_NAME.equals(unTrimmedActionName)) {
+                List langs =3D jParams.getSite().getLanguageSettingsAsLoca=
les(
+                        true);
+                // we will unlock all languages
+                for (Iterator iterator =3D langs.iterator(); iterator.hasN=
ext();) {
+                    Locale locale =3D (Locale) iterator.next();
+                    try {
+                        instance =3D instanceManager
+                                .getWorkflowInstanceByObjectKey(objectKey,
+                                        locale.getLanguage());
+                    } catch (ObjectRetrievalFailureException ex) {
+                        continue;
+                    }
+                    final List steps =3D instance.getWorkflow().getSteps();
+                    int startIndex =3D steps.indexOf(instance.getStep()) +=
 1;
+                    // skip if this instance is on the first step
+                    if (startIndex =3D=3D 1) {
+                        continue;
+                    }
+                    changeStatus(locale.getLanguage(), jParams, objectKey,
+                            processName,
+                            EntryLoadRequest.WAITING_WORKFLOW_STATE);
+                    historyManager.saveWorkflowHistory(ServicesRegistry
+                            .getInstance().getJahiaUserManagerService()
+                            .lookupUser(instance.getAuthorEmail())
+                            .getUsername(), jParams.getUser().getUsername(=
),
+                            processName, LOCK_ACTION_NAME, objectKey, loca=
le
+                                    .getLanguage(), comment);
+                    addActionToMailQueue(jParams, actionName, objectKey, l=
ocale
+                            .getLanguage(), comment, isStartStep, false,
+                            instance, userNotifData);
+                }
+                instance =3D null;
             } else {
                 instance =3D instanceManager.getWorkflowInstanceByObjectKe=
y(objectKey, languageCode);
                 isFinished =3D instanceManager.stepForwardWorkflow(jParams=
.getUser().getUsername(), objectKey,
@@ -653,12 +701,9 @@
                         objectKey, languageCode, comment);
             }
             // Send email
-            addActionToMailQueue(jParams, actionName, objectKey, languageC=
ode, comment, isStartStep, isFinished, instance, userNotifData);
-//                    } catch (Throwable e) {
-//                        throw new RuntimeException(e);
-//                    }
-//                }
-//            });
+            if (instance !=3D null) {
+                addActionToMailQueue(jParams, actionName, objectKey, langu=
ageCode, comment, isStartStep, isFinished, instance, userNotifData);
+            }
         } catch (Throwable e) {
             log.warn("Error during workflow of object " + objectKey + " in=
 language " + languageCode +
                     " with process " + processName, e);

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to