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 @@ + + + + + + + + + + + + Index: plugins/optional/workflow-repair/resources_dynamic/js/dialog.js =================================================================== RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/workflow-repair/resources_dynamic/js/dialog.js,v retrieving revision 1.1 diff -u -r1.1 dialog.js --- plugins/optional/workflow-repair/resources_dynamic/js/dialog.js 30 Jan 2009 10:34:15 -0000 1.1 +++ plugins/optional/workflow-repair/resources_dynamic/js/dialog.js 11 Feb 2009 15:37:59 -0000 @@ -23,7 +23,7 @@ ANWRT_Plugin_Workflow_Repair.box = new SDialog("ANWRT_Plugin_Workflow_Repair", "", getPluginResourcesUrl(ANWRT_Plugin_Workflow_Repair.plugin) + "/img/workflow_repair_16.gif", - 290, 140, config, ANWRT_Plugin_Workflow_Repair); + 290, 190, config, ANWRT_Plugin_Workflow_Repair); ANWRT_Plugin_Workflow_Repair.box.paint(); Tools.loadStyle(ANWRT_Plugin_Workflow_Repair.box.ui.iframe.contentWindow.document, context.contextPath + "/kernel/resources/css/dialog.css"); @@ -62,11 +62,21 @@ var workflowType = _document.getElementById("workflow-types").value; var site = _document.getElementById("sites").value; var removePublication = _document.getElementById("remove_publication").checked; + var workflowEditedStep = _document.getElementById("workflow_edited_step").checked; + var actionWorkflowId = _document.getElementById("action_workflow_id").value; + + var reg1=new RegExp("\\d","g"); + + if (workflowEditedStep == true && (actionWorkflowId == '' || !actionWorkflowId.match(reg1))) + { + alert(""); + return; + } ANWRT_Plugin_Workflow_Repair.box.close(); //Launch analysis and repair - var args = "workflowType=" + workflowType + "&site=" + site + "&removePublication=" + removePublication; + var args = "workflowType=" + workflowType + "&site=" + site + "&removePublication=" + removePublication + "&workflowEditedStep=" + workflowEditedStep + "&actionWorkflowId=" + actionWorkflowId; var result = Tools.postFromUrl(getPluginDirectUrl(plugin) + "/workflow-repair/repair.xml", args); if (result == null) { @@ -103,4 +113,20 @@ ANWRT_Plugin_Workflow_Repair.cancel = function() { ANWRT_Plugin_Workflow_Repair.box.close(); +} + +ANWRT_Plugin_Workflow_Repair.checkSetActionId = function() +{ + var _document = ANWRT_Plugin_Workflow_Repair.box.ui.iframe.contentWindow.document; + var workflowEditedStep = _document.getElementById("workflow_edited_step"); + if (workflowEditedStep.checked) + { + _document.getElementById("action_workflow_id").disabled = false; + workflowEditedStep.checked = true; + } + else + { + _document.getElementById("action_workflow_id").disabled = true; + workflowEditedStep.checked = false; + } } \ No newline at end of file