2009/2/19 Francesco Chicchiriccò <[email protected]>
> On 19-02-2009 12:53, Bartosz Oudekerk wrote: > >> 2009/2/19 Fabiano Izzo<[email protected]>: >> >> >>> Bartosz Oudekerk wrote: >>> >>> >>>> 2009/2/18 Jasha Joachimsthal<[email protected]>: >>>> >>>> >>>>> 2009/2/18 Fabiano Izzo<[email protected]> >>>>> >>>>> >>>>>> Thanks a lot Jasha! >>>>>> This solved my problem! >>>>>> >>>>>> I have another question. >>>>>> Is it possible to invoke the publication of a document through hippo >>>>>> repository java adapter?...or should I use another way? >>>>>> >>>>>> >>>>> the Quick& dirty way is to put the document also in the www tree of >>>>> the >>>>> repository namespace. >>>>> >>>>> >>>> This way it is not good to me, cause I have to publish all documents >>> through >>> workflow. I can't do this going out from workflow actions. >>> >>> >> >> May I ask why, as what Jasha and I described will have functionally >> the same result. >> > Only if you consider the default workflow (ReviewedActions). > What if Fabiano was using a different workflow (as I know ;-)) that - for > example - is sending an e-mail when a document is published? You could implement the mailing in the front end on adding a document ;) > > Should he try to mimic the workflow behaviour (so far copying the document, > modifying properties and sending e-mails) or should he better delegate to > workflow such actions and decisions? > That's we we think that the best way would be to invoke the workflow as per > CMS' web interface. Any idea? If you want to invoke the workflow from the front end, you have create a matcher in the CMS for a URL that does 1) Set a property on your documents for the last saved date. It name comes from nl.hippo.cms.Constants.LAST_SAVED_PROPERTY_NAME, namespace nl.hippo.cms.Constants.CMS_1_0_NAMESPACE and value Date newDate = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); sdf.setLenient(false); String lastSaved = sdf.format(newDate); 2) automatic login into the CMS. See login.js for the current login process and you can't use the systemuser (its username and displayname are not the same) or siteuser (same reason plus it doesn't have write access and no rights to publish). 3) When the user is logged in, you have to create a flowscript function that checks if there's already a workflow for that document. If not create one. then invoke the workflow action for publishing. An example from one of our projects (flowscript, server side): cocoon.load("site:/actions/flow/actions.js"); // loads the actions.js that handles more workflow stuff /* * function that does a request for publication for each document in a list that is selected */ function requestBulkPublication(){ var defaultWorkflowName = "ReviewedActions"; var repositoryRoot = cocoon.parameters["repositoryRoot"]; //in the sitemap <map:parameter name="repositoryRoot" value="{repository:root}"/> var repositoryFilesPath = cocoon.parameters["repositoryFilesPath"]; //in the sitemap <map:parameter name="repositoryFilesPath" value="{repository:filesPath}"/> var uris = new ArrayList(); var cache = cocoon.getComponent(Store.ROLE+"/EventAware"); var httpState = authentication.getHttpState(); var succeeded = new ArrayList(); var failed = new ArrayList(); var selectedDocuments = cocoon.request.get("selectedDocuments"); if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("selectedDocuments: " + selectedDocuments); cocoon.log.debug("repositoryFilesPath: " + repositoryFilesPath); } if(selectedDocuments instanceof Packages.java.lang.String){ //only 1 document selected if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("only one document selected"); } var sdList = new ArrayList(); sdList.add(selectedDocuments); var it = sdList.iterator(); } else{ // multiple documents selected var it = selectedDocuments.iterator(); } while (it.hasNext()) { var key = it.next(); var newUri = repositoryFilesPath + key; //in the sitemap: <map:parameter name="uriPrefix" value="{repository:files}"/> var workflowId = WebDAVHelper.propfindAsString(cache,cocoon.parameters["uriPrefix"]+key, " http://hippo.nl/cms/1.0", "workflowId", httpState); if ( !(workflowId == null || workflowId == 0 || workflowId.equals("")) ) { // existing property for workflowId usingWorkflowDo(function(workflowComp) { var workflowName = workflowComp.getWorkflowName(workflowId); if (workflowName == null) { if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("workflowName is null, creating new worfklow for: " + newUri); } startWorkflowForExistingDocument(cocoon.parameters["uriPrefix"], key); // start workflow } }); } else { if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("No workflowId, creating new worfklow for: " + newUri); } startWorkflowForExistingDocument(cocoon.parameters["uriPrefix"], key); } var p = new HashMap(); p.put("publicationDateMode", "now"); p.put("unpublicationDateMode", "never"); p.put("publicationDate", null); p.put("unpublicationDate", null); p.put("actionId", "2005"); // the id for requestPublication p.put("standardUIAction", null); //params.add(p); //workflow.invokeAction(resourceId, workflowActionId, params, uriPrefix) if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("trying to request publication for : " + newUri); } if(!workflow.invokeAction(newUri,"2005", p, repositoryRoot)) // 2005 is the id for requestPublication { cocoon.log.error("Failed to request publication for: "+newUri); failed.add(key); } else { succeeded.add(key); } } cocoon.sendPage("reqPublicationResult",{succeeded:succeeded,failed:failed}); // go to a pipeline that displays the result of the bulk request } I hope this helps you :) -- Jasha Joachimsthal [email protected] - [email protected] www.onehippo.com Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466 San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA 94952-5100 +1 (707) 773-4646 ******************************************** Hippocms-dev: Hippo CMS development public mailinglist Searchable archives can be found at: MarkMail: http://hippocms-dev.markmail.org Nabble: http://www.nabble.com/Hippo-CMS-f26633.html
