Index: plugins/optional/workflow-repair/i18n/messages_en.xml =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/i18n/messages_en.xml,v retrieving revision 1.1 diff -u -r1.1 messages_en.xml --- plugins/optional/workflow-repair/i18n/messages_en.xml 30 Jan 2009 10:34:15 -0000 1.1 +++ plugins/optional/workflow-repair/i18n/messages_en.xml 11 Feb 2009 15:37:59 -0000 @@ -21,6 +21,8 @@ Sites All Remove publication label + Set documents workflow in edited step + ID step action OK Cancel @@ -35,5 +37,6 @@ non JCR contents An error occured during content's analysis. + Set a valid action id. \ No newline at end of file Index: plugins/optional/workflow-repair/i18n/messages_fr.xml =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/i18n/messages_fr.xml,v retrieving revision 1.1 diff -u -r1.1 messages_fr.xml --- plugins/optional/workflow-repair/i18n/messages_fr.xml 30 Jan 2009 10:34:15 -0000 1.1 +++ plugins/optional/workflow-repair/i18n/messages_fr.xml 11 Feb 2009 15:37:59 -0000 @@ -21,6 +21,8 @@ Sites Tous Retirer le label de publication + Etat workflow édité + ID de l'action OK Annuler @@ -36,4 +38,6 @@ Une erreur inconnue est survenue + Veuillez saisir un id d'action valide. + \ No newline at end of file Index: plugins/optional/workflow-repair/sitemap.xmap =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/sitemap.xmap,v retrieving revision 1.1 diff -u -r1.1 sitemap.xmap --- plugins/optional/workflow-repair/sitemap.xmap 30 Jan 2009 10:34:15 -0000 1.1 +++ plugins/optional/workflow-repair/sitemap.xmap 11 Feb 2009 15:37:59 -0000 @@ -37,6 +37,8 @@ + + Index: plugins/optional/workflow-repair/src/org/ametys/anycontent/plugins/workflow_repair/action/RepairAction.java =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/src/org/ametys/anycontent/plugins/workflow_repair/action/RepairAction.java,v retrieving revision 1.2 diff -u -r1.2 RepairAction.java --- plugins/optional/workflow-repair/src/org/ametys/anycontent/plugins/workflow_repair/action/RepairAction.java 10 Feb 2009 13:23:25 -0000 1.2 +++ plugins/optional/workflow-repair/src/org/ametys/anycontent/plugins/workflow_repair/action/RepairAction.java 11 Feb 2009 15:37:59 -0000 @@ -10,14 +10,16 @@ import org.apache.cocoon.acting.ServiceableAction; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; - import org.ametys.anycontent.plugins.anycontent.repository.jcr.JCRContent; import org.ametys.anycontent.plugins.anycontent.repository.jcr.JCRRepository; import org.ametys.anycontent.plugins.web.repository.Repository; import org.ametys.anycontent.repository.Content; import org.ametys.anycontent.repository.ContentQuery; import org.ametys.anycontent.repository.RepositoryException; +import org.ametys.anycontent.workflow.CheckRight; +import org.ametys.anycontent.workflow.ContentWorkflowHelper; import org.ametys.anycontent.workflow.Workflow; +import org.ametys.runtime.user.User; import com.opensymphony.workflow.InvalidActionException; import com.opensymphony.workflow.WorkflowException; @@ -42,8 +44,10 @@ String site = parameters.getParameter("site"); String workflowType = parameters.getParameter("workflowType"); String removePublication = parameters.getParameter("removePublication"); + String workflowEditedStep = parameters.getParameter("workflowEditedStep"); + String actionWorkflowId = parameters.getParameter("actionWorkflowId"); - if (site == null || workflowType == null || removePublication == null) + if (site == null || workflowType == null || removePublication == null || workflowEditedStep == null) { throw new IllegalArgumentException(); } @@ -77,7 +81,7 @@ if (content instanceof JCRContent) { JCRContent jcrContent = (JCRContent) content; - if (_repairContent(jcrContent, workflowType, removePublication, site)) + if (_repairContent(jcrContent, workflowType, removePublication, site, workflowEditedStep, actionWorkflowId)) { badWorkflowContents++; } @@ -115,7 +119,7 @@ return results; } - private boolean _repairContent (JCRContent jcrContent, String workflowType, String removePublication, String site) throws RepositoryException + private boolean _repairContent (JCRContent jcrContent, String workflowType, String removePublication, String site, String workflowEditedStep, String actionWorkflowId) throws RepositoryException { boolean badWorkflowContents = false; long wId = jcrContent.getWorkflowId(); @@ -142,6 +146,12 @@ _removePublicationLabel(jcrContent); } + // Remove publication label if necessary + if ("true".equals(workflowEditedStep)) + { + _setStepWorkflow(jcrContent, actionWorkflowId); + } + getLogger().info("Workflow of content '" + jcrContent.getName() + "' in site '" + (site.equals("") ? jcrContent.getSite() : site) + "' with workflow type '" + workflowType + "' has been repaired."); } else @@ -152,6 +162,31 @@ return badWorkflowContents; } + private void _setStepWorkflow(JCRContent jcrContent, String actionWorkflowId) throws RepositoryException + { + Workflow workflow = Workflow.getInstance(); + Map workflowParameters = new HashMap(); + + // Transmettre le manager + workflowParameters.put(Workflow.MANAGER_KEY, manager); + // Transmettre l'object model + workflowParameters.put(Workflow.OBJECT_MODEL_KEY, null); + // Transmettre l'uri complete du contenu + workflowParameters.put(Workflow.CONTEXT_URI_KEY, ""); + // Transmettre le prefix pour la redirection + workflowParameters.put(Workflow.CONTEXT_URI_PREFIX_KEY, ""); + // Transmettre le content + workflowParameters.put(ContentWorkflowHelper.CONTENT_KEY, jcrContent); + // Ne pas vérifier les droits + workflowParameters.put(CheckRight.CHECK_RIGHTS, "false"); + + // Création d'un utilisateur "Daemon" + User daemon = new User("daemon", "Workflow", ""); + + workflow.doAction(jcrContent.getWorkflowId(), Integer.valueOf(actionWorkflowId), daemon, null, workflowParameters); + + } + /** * Checks if the given content has 'FR' label and removes it if yes. * @param jcrContent Index: plugins/optional/workflow-repair/pages/workflow-repair/dialog.xsl =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/pages/workflow-repair/dialog.xsl,v retrieving revision 1.1 diff -u -r1.1 dialog.xsl --- plugins/optional/workflow-repair/pages/workflow-repair/dialog.xsl 30 Jan 2009 10:34:15 -0000 1.1 +++ plugins/optional/workflow-repair/pages/workflow-repair/dialog.xsl 11 Feb 2009 15:37:59 -0000 @@ -57,6 +57,18 @@ + + + + + + + + + + + +