. Root webapp name "ROOT" now fixed for a web project

. Changes for NameMatcher usage in avm sync service compare() method
. Abstraction of AVM web-client workflow utils methods into AVMWorkflowUtil class
. Refactor of SubmitDialog to use workflow util
. Refactor of CreateWebContentWizard to use workflow utils
 - now launches a workflow on submit

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4531 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-12-06 16:06:54 +00:00
parent e8d0027c9b
commit eba3b28fbe
10 changed files with 323 additions and 197 deletions

View File

@@ -0,0 +1,146 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.GUID;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.workflow.WorkflowUtil;
/**
* AVM Specific workflow related helper methods.
*
* @author Kevin Roast
*/
public class AVMWorkflowUtil extends WorkflowUtil
{
private static final String STORE_WORKFLOW_SYSTEM = "workflow-system";
private static final String FOLDER_PACKAGES = "packages";
/**
* Return the AVM workflow package root folder path - creating the default
* store and root folder if required.
*
* @param avmService AVMService to use
*
* @return AVM Root package path
*/
public static String getAVMPackageRoot(AVMService avmService)
{
String packagesRoot = STORE_WORKFLOW_SYSTEM + ":/" + FOLDER_PACKAGES;
AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesRoot);
if (packagesDesc == null)
{
avmService.createAVMStore(STORE_WORKFLOW_SYSTEM);
avmService.createDirectory(STORE_WORKFLOW_SYSTEM + ":/", FOLDER_PACKAGES);
}
return packagesRoot;
}
/**
* Create an AVM layered workflow package against the specified sandbox path.
*
* @param avmService AVMService to use
* @param sandboxPath The sandbox path to layer the package over
*
* @return Path to the layered package.
*/
public static String createAVMLayeredPackage(AVMService avmService, String sandboxPath)
{
String packagesRoot = getAVMPackageRoot(avmService);
String packageName = GUID.generate();
avmService.createLayeredDirectory(sandboxPath, packagesRoot, packageName);
return packagesRoot + "/" + packageName;
}
/**
* Serialize the workflow params to a content stream
*
* @param params Serializable workflow params
* @param workflowRef The noderef to write the property too
*/
public static void serializeWorkflowParams(Serializable params, NodeRef workflowRef)
{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(params);
oos.close();
// write the serialized Map as a binary content stream - like database blob!
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentWriter writer = cs.getWriter(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS, true);
writer.setMimetype(MimetypeMap.MIMETYPE_BINARY);
writer.putContent(new ByteArrayInputStream(baos.toByteArray()));
}
catch (IOException ioerr)
{
throw new AlfrescoRuntimeException("Unable to serialize workflow default parameters: " + ioerr.getMessage());
}
}
/**
* Deserialize the default workflow params from a content stream
*
* @param workflowRef The noderef to write the property too
*
* @return Serializable workflow params
*/
public static Serializable deserializeWorkflowParams(NodeRef workflowRef)
{
try
{
// restore the serialized Map from a binary content stream - like database blob!
Serializable params = null;
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS);
if (reader != null)
{
ObjectInputStream ois = new ObjectInputStream(reader.getContentInputStream());
params = (Serializable)ois.readObject();
ois.close();
}
return params;
}
catch (IOException ioErr)
{
throw new AlfrescoRuntimeException("Unable to deserialize workflow default parameters: " + ioErr.getMessage());
}
catch (ClassNotFoundException classErr)
{
throw new AlfrescoRuntimeException("Unable to deserialize workflow default parameters: " + classErr.getMessage());
}
}
}

View File

@@ -16,12 +16,12 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent; import javax.faces.event.ValueChangeEvent;
@@ -30,17 +30,23 @@ import javax.faces.model.SelectItem;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.*; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.workflow.*; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
@@ -55,7 +61,6 @@ import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.FormProcessor; import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition; import org.alfresco.web.forms.Rendition;
import org.alfresco.web.forms.RenditionImpl;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.wcm.component.UIUserSandboxes; import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -123,6 +128,7 @@ public class CreateWebContentWizard extends BaseContentWizard
this.avmBrowseBean = avmBrowseBean; this.avmBrowseBean = avmBrowseBean;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Wizard implementation // Wizard implementation
@@ -228,94 +234,112 @@ public class CreateWebContentWizard extends BaseContentWizard
{ {
WorkflowDefinition wd = null; WorkflowDefinition wd = null;
Map<QName, Serializable> parameters = null; Map<QName, Serializable> parameters = null;
// get the workflow definition and parameters // get the workflow definition and parameters
{ final Node website = this.avmBrowseBean.getWebsite();
final Node website = this.avmBrowseBean.getWebsite(); final List<ChildAssociationRef> webFormRefs = this.nodeService.getChildAssocs(
final List<ChildAssociationRef> webFormRefs = this.nodeService.getChildAssocs(
website.getNodeRef(), WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL); website.getNodeRef(), WCMAppModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : webFormRefs) for (ChildAssociationRef ref : webFormRefs)
{
final String formName = (String)
this.nodeService.getProperty(ref.getChildRef(), WCMAppModel.PROP_FORMNAME);
if (formName.equals(this.getForm().getName()))
{ {
final String formName = (String) if (LOGGER.isDebugEnabled())
this.nodeService.getProperty(ref.getChildRef(), WCMAppModel.PROP_FORMNAME); LOGGER.debug("loading workflowRefs for " + formName);
if (formName.equals(this.getForm().getName()))
final List<ChildAssociationRef> workflowRefs =
this.nodeService.getChildAssocs(ref.getChildRef(),
WCMAppModel.ASSOC_WORKFLOWDEFAULTS,
RegexQNamePattern.MATCH_ALL);
if (workflowRefs.size() == 0)
{ {
System.err.println("loading workflowRefs for " + formName); throw new AlfrescoRuntimeException("no workflow parameters found for form " + formName);
final List<ChildAssociationRef> workflowRefs = }
this.nodeService.getChildAssocs(ref.getChildRef(), if (workflowRefs.size() > 1)
WCMAppModel.ASSOC_WORKFLOWDEFAULTS, {
RegexQNamePattern.MATCH_ALL); throw new AlfrescoRuntimeException("found more than one workflow parameters node for " + formName);
if (workflowRefs.size() == 0) }
{
throw new RuntimeException("no workflow parameters found for form " + formName); final NodeRef workflowRef = workflowRefs.get(0).getChildRef();
} final String workflowName = (String)this.nodeService.getProperty(workflowRef, WCMAppModel.PROP_WORKFLOW_NAME);
if (workflowRefs.size() > 1)
{ if (LOGGER.isDebugEnabled())
throw new RuntimeException("found more than one workflow parameters node for " + formName); LOGGER.debug("using workflow " + workflowName + " for form " + formName);
} wd = this.workflowService.getDefinitionByName("jbpm$" + workflowName);
final NodeRef workflowRef = workflowRefs.get(0).getChildRef(); // deserialize the workflow parameters
final String workflowName = (String)this.nodeService.getProperty(workflowRef, WCMAppModel.PROP_WORKFLOW_NAME); parameters = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(workflowRef);
if (workflowName == null)
{ break;
throw new RuntimeException("no workflow found for form " + formName); }
} }
System.err.println("using workflow " + workflowName + " for form " + formName);
wd = this.workflowService.getDefinitionByName("jbpm$" + workflowName); if (LOGGER.isDebugEnabled())
LOGGER.debug("creating workflow package");
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ContentReader cr = this.contentService.getReader(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS); // create package paths (layered to user sandbox area as target)
if (cr == null) String webapp = (String)website.getProperties().get(WCMAppModel.PROP_DEFAULTWEBAPP);
{ String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox());
parameters = new HashMap<QName, Serializable>(); String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, sandboxPath);
}
else // construct diffs for selected items for submission
{ List<AVMDifference> diffs = new ArrayList<AVMDifference>(8);
cr.getContent(baos); for (Rendition rendition : this.getRenditions())
{
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); String renditionPath = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond();
final ObjectInputStream ois = new ObjectInputStream(bais); int webappIndex = renditionPath.indexOf('/' + webapp);
parameters = (Map<QName, Serializable>)ois.readObject(); renditionPath = renditionPath.substring(webappIndex);
} String srcPath = sandboxPath + renditionPath;
break; String destPath = packagesPath + renditionPath;
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
diffs.add(diff);
}
String instancePath = AVMNodeConverter.ToAVMVersionPath(this.formInstanceData.getNodeRef()).getSecond();
int webappIndex = instancePath.indexOf('/' + webapp);
instancePath = instancePath.substring(webappIndex);
String srcPath = sandboxPath + instancePath;
String destPath = packagesPath + instancePath;
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
diffs.add(diff);
// write changes to layer so files are marked as modified
this.avmSyncService.update(diffs, null, true, true, false, false, null, null);
// convert package to workflow package
AVMNodeDescriptor packageDesc = this.avmService.lookup(-1, packagesPath);
NodeRef packageNodeRef = this.workflowService.createPackage(
AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath()));
this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true);
parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef);
if (LOGGER.isDebugEnabled())
LOGGER.debug("starting workflow " + wd + " with parameters " + parameters);
// start the workflow to get access to the start task
WorkflowPath path = this.workflowService.startWorkflow(wd.id, parameters);
if (path != null)
{
// extract the start task
List<WorkflowTask> tasks = this.workflowService.getTasksForWorkflowPath(path.id);
if (tasks.size() == 1)
{
WorkflowTask startTask = tasks.get(0);
if (startTask.state == WorkflowTaskState.IN_PROGRESS)
{
// end the start task to trigger the first 'proper' task in the workflow
this.workflowService.endTask(startTask.id, null);
} }
} }
} }
System.err.println("creating workflow package");
final NodeRef workflowPackageNodeRef = this.workflowService.createPackage(null);
// doesn't work yet. need to use ASPECT_REFERENCES_NODE to get it to deal with avm nodes
// and we need some fixes from dave before we can enable.
// QName qn = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
// QName.createValidLocalName(this.formInstanceData.getName()));
// String s = AVMNodeConverter.ToAVMVersionPath(this.formInstanceData.getNodeRef()).getSecond();
// s = s.replaceFirst(AVMConstants.STORE_PREVIEW, AVMConstants.STORE_MAIN);
// System.err.println("adding " + s + " to workflow package with qname" + qn);
// this.nodeService.addChild(workflowPackageNodeRef,
// AVMNodeConverter.ToNodeRef(-1, s),
// ContentModel.ASSOC_CONTAINS,
// qn);
// for (Rendition rendition : this.getRenditions())
// {
// qn = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
// QName.createValidLocalName(rendition.getName()));
// s = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond();
// s = s.replaceFirst(AVMConstants.STORE_PREVIEW, AVMConstants.STORE_MAIN);
// System.err.println("adding " + s + " to workflow package with qname " + qn);
//
// this.nodeService.addChild(workflowPackageNodeRef,
// AVMNodeConverter.ToNodeRef(-1, s),
// ContentModel.ASSOC_CONTAINS,
// qn);
// }
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowPackageNodeRef);
System.err.println("starting workflow " + wd + " with parameters " + parameters);
final WorkflowPath wp = this.workflowService.startWorkflow(wd.getId(), parameters);
} }
else else
{ {
System.err.println("************* not starting workflow"); if (LOGGER.isDebugEnabled())
LOGGER.debug("************* not starting workflow");
} }
// return the default outcome // return the default outcome
return outcome; return outcome;
} }
@@ -351,7 +375,6 @@ public class CreateWebContentWizard extends BaseContentWizard
path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW); path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW);
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null) if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
{ {
final Document formInstanceData = fs.parseXML(this.content); final Document formInstanceData = fs.parseXML(this.content);
path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData); path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData);
@@ -360,7 +383,6 @@ public class CreateWebContentWizard extends BaseContentWizard
this.fileName = sb[1]; this.fileName = sb[1];
} }
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("reseting layer " + path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE); LOGGER.debug("reseting layer " + path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE);
@@ -574,6 +596,7 @@ public class CreateWebContentWizard extends BaseContentWizard
return this.startWorkflow; return this.startWorkflow;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Action event handlers // Action event handlers

View File

@@ -16,10 +16,6 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
@@ -37,11 +33,8 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowService;
@@ -162,6 +155,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Created website folder node with name: " + this.name); logger.debug("Created website folder node with name: " + this.name);
// TODO: check that this dns is unique by querying existing store properties for a match
String avmStore = DNSNameMangler.MakeDNSName(this.dnsName); String avmStore = DNSNameMangler.MakeDNSName(this.dnsName);
// apply the uifacets aspect - icon, title and description props // apply the uifacets aspect - icon, title and description props
@@ -255,7 +249,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
// persist workflow default params // persist workflow default params
if (workflow.getParams() != null) if (workflow.getParams() != null)
{ {
serializeWorkflowParams((Serializable)workflow.getParams(), workflowRef); AVMWorkflowUtil.serializeWorkflowParams((Serializable)workflow.getParams(), workflowRef);
} }
} }
@@ -294,7 +288,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
// persist workflow default params // persist workflow default params
if (workflow.getParams() != null) if (workflow.getParams() != null)
{ {
serializeWorkflowParams((Serializable)workflow.getParams(), workflowRef); AVMWorkflowUtil.serializeWorkflowParams((Serializable)workflow.getParams(), workflowRef);
} }
// add filename pattern aspect if a filename pattern has been applied // add filename pattern aspect if a filename pattern has been applied
@@ -306,32 +300,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
} }
} }
} }
/**
* Serialize the workflow params to a content stream
*
* @param params Serializable workflow params
* @param workflowRef The noderef to write the property too
*/
public static void serializeWorkflowParams(Serializable params, NodeRef workflowRef)
{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(params);
oos.close();
// write the serialized Map as a binary content stream - like database blob!
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentWriter writer = cs.getWriter(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS, true);
writer.setMimetype(MimetypeMap.MIMETYPE_BINARY);
writer.putContent(new ByteArrayInputStream(baos.toByteArray()));
}
catch (IOException ioerr)
{
throw new AlfrescoRuntimeException("Unable to serialize workflow default parameters: " + ioerr.getMessage());
}
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------

View File

@@ -16,26 +16,20 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form; import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.RenderingEngineTemplate; import org.alfresco.web.forms.RenderingEngineTemplate;
@@ -109,7 +103,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
if (wfDef != null) if (wfDef != null)
{ {
WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle()); WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle());
wfWrapper.setParams((Map<QName, Serializable>)deserializeWorkflowParams(wfRef)); wfWrapper.setParams((Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(wfRef));
if (wfDef.startTaskDefinition != null) if (wfDef.startTaskDefinition != null)
{ {
wfWrapper.setType(wfDef.startTaskDefinition.metadata.getName()); wfWrapper.setType(wfDef.startTaskDefinition.metadata.getName());
@@ -154,7 +148,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
if (wfDef != null) if (wfDef != null)
{ {
WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle()); WorkflowWrapper wfWrapper = new WorkflowWrapper(wfName, wfDef.getTitle());
wfWrapper.setParams((Map<QName, Serializable>)deserializeWorkflowParams(wfRef)); wfWrapper.setParams((Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(wfRef));
wfWrapper.setFilenamePattern((String)this.nodeService.getProperty( wfWrapper.setFilenamePattern((String)this.nodeService.getProperty(
wfRef, WCMAppModel.PROP_FILENAMEPATTERN)); wfRef, WCMAppModel.PROP_FILENAMEPATTERN));
if (wfDef.startTaskDefinition != null) if (wfDef.startTaskDefinition != null)
@@ -213,37 +207,4 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
this.nodeService.removeChild(nodeRef, ref.getChildRef()); this.nodeService.removeChild(nodeRef, ref.getChildRef());
} }
} }
/**
* Deserialize the default workflow params from a content stream
*
* @param workflowRef The noderef to write the property too
*
* @return Serializable workflow params
*/
public static Serializable deserializeWorkflowParams(NodeRef workflowRef)
{
try
{
// restore the serialized Map from a binary content stream - like database blob!
Serializable params = null;
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(workflowRef, WCMAppModel.PROP_WORKFLOWDEFAULTS);
if (reader != null)
{
ObjectInputStream ois = new ObjectInputStream(reader.getContentInputStream());
params = (Serializable)ois.readObject();
ois.close();
}
return params;
}
catch (IOException ioErr)
{
throw new AlfrescoRuntimeException("Unable to deserialize workflow default parameters: " + ioErr.getMessage());
}
catch (ClassNotFoundException classErr)
{
throw new AlfrescoRuntimeException("Unable to deserialize workflow default parameters: " + classErr.getMessage());
}
}
} }

View File

@@ -45,8 +45,8 @@ import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskState; import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.GUID;
import org.alfresco.util.ISO8601DateFormat; import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.util.NameMatcher;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
@@ -72,6 +72,7 @@ public class SubmitDialog extends BaseDialogBean
protected AVMBrowseBean avmBrowseBean; protected AVMBrowseBean avmBrowseBean;
protected WorkflowService workflowService; protected WorkflowService workflowService;
protected AVMSyncService avmSyncService; protected AVMSyncService avmSyncService;
protected NameMatcher nameMatcher;
/** /**
* @param avmService The AVM Service to set. * @param avmService The AVM Service to set.
@@ -105,6 +106,14 @@ public class SubmitDialog extends BaseDialogBean
this.workflowService = workflowService; this.workflowService = workflowService;
} }
/**
* @param nameMatcher The nameMatcher to set.
*/
public void setNameMatcher(NameMatcher nameMatcher)
{
this.nameMatcher = nameMatcher;
}
/** /**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map) * @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map)
*/ */
@@ -135,7 +144,7 @@ public class SubmitDialog extends BaseDialogBean
{ {
NodeRef wfDefaultsRef = wfRefs.get(0).getChildRef(); NodeRef wfDefaultsRef = wfRefs.get(0).getChildRef();
String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME); String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME);
Map<QName, Serializable> params = (Map<QName, Serializable>)EditWebsiteWizard.deserializeWorkflowParams( Map<QName, Serializable> params = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(
wfDefaultsRef); wfDefaultsRef);
this.formWorkflowMap.put(form, new FormWorkflowWrapper(wfName, params)); this.formWorkflowMap.put(form, new FormWorkflowWrapper(wfName, params));
} }
@@ -239,7 +248,6 @@ public class SubmitDialog extends BaseDialogBean
*/ */
public String[] getWorkflowSelectedValue() public String[] getWorkflowSelectedValue()
{ {
// TODO: select default!
return this.workflowSelectedValue; return this.workflowSelectedValue;
} }
@@ -259,7 +267,7 @@ public class SubmitDialog extends BaseDialogBean
if (this.workflowItems == null) if (this.workflowItems == null)
{ {
// ensure all workflows have been collected from any form generated assets // ensure all workflows have been collected from any form generated assets
calculateSubmitItems(); calcluateListItemsAndWorkflows();
// add the list of workflows for the website itself to the set // add the list of workflows for the website itself to the set
NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef(); NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef();
@@ -269,7 +277,7 @@ public class SubmitDialog extends BaseDialogBean
{ {
NodeRef wfDefaultsRef = ref.getChildRef(); NodeRef wfDefaultsRef = ref.getChildRef();
String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME); String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME);
Map<QName, Serializable> params = (Map<QName, Serializable>)EditWebsiteWizard.deserializeWorkflowParams( Map<QName, Serializable> params = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(
wfDefaultsRef); wfDefaultsRef);
this.workflows.add(new FormWorkflowWrapper(wfName, params)); this.workflows.add(new FormWorkflowWrapper(wfName, params));
} }
@@ -285,7 +293,7 @@ public class SubmitDialog extends BaseDialogBean
item.setDescription(workflowDef.getDescription()); item.setDescription(workflowDef.getDescription());
item.setImage(WebResources.IMAGE_WORKFLOW_32); item.setImage(WebResources.IMAGE_WORKFLOW_32);
items.add(item); items.add(item);
// add first as default TODO: what is correct here? // add first workflow as default selection
if (workflowSelectedValue == null) if (workflowSelectedValue == null)
{ {
workflowSelectedValue = new String[]{workflowDef.getName()}; workflowSelectedValue = new String[]{workflowDef.getName()};
@@ -297,37 +305,52 @@ public class SubmitDialog extends BaseDialogBean
return this.workflowItems; return this.workflowItems;
} }
/**
* @return the List of bean items to show in the Submit list
*/
public List<ItemWrapper> getSubmitItems() public List<ItemWrapper> getSubmitItems()
{ {
if (this.submitItems == null) if (this.submitItems == null)
{ {
// this method builds all submit and warning item data structures // this method builds all submit and warning item data structures
calculateSubmitItems(); calcluateListItemsAndWorkflows();
} }
return this.submitItems; return this.submitItems;
} }
/**
* @return size of the submit list
*/
public int getSubmitItemsSize() public int getSubmitItemsSize()
{ {
return getSubmitItems().size(); return getSubmitItems().size();
} }
/**
* @return the List of bean items to show in the Warning list
*/
public List<ItemWrapper> getWarningItems() public List<ItemWrapper> getWarningItems()
{ {
if (this.warningItems == null) if (this.warningItems == null)
{ {
// this method builds all submit and warning item data structures // this method builds all submit and warning item data structures
calculateSubmitItems(); calcluateListItemsAndWorkflows();
} }
return this.warningItems; return this.warningItems;
} }
/**
* @return size of the warning list
*/
public int getWarningItemsSize() public int getWarningItemsSize()
{ {
return this.getWarningItems().size(); return this.getWarningItems().size();
} }
private void calculateSubmitItems() /**
* Calculate the lists of Submittable Items, Warning items and the list of available workflows.
*/
private void calcluateListItemsAndWorkflows()
{ {
// TODO: start txn here? // TODO: start txn here?
List<AVMNodeDescriptor> selected; List<AVMNodeDescriptor> selected;
@@ -335,8 +358,7 @@ public class SubmitDialog extends BaseDialogBean
{ {
String userStore = this.avmBrowseBean.getSandbox() + ":/"; String userStore = this.avmBrowseBean.getSandbox() + ":/";
String stagingStore = this.avmBrowseBean.getStagingStore() + ":/"; String stagingStore = this.avmBrowseBean.getStagingStore() + ":/";
// TODO Pass the globalPathExcluder NameMatcher instead of null. List<AVMDifference> diffs = avmSyncService.compare(-1, userStore, -1, stagingStore, nameMatcher);
List<AVMDifference> diffs = avmSyncService.compare(-1, userStore, -1, stagingStore, null);
selected = new ArrayList<AVMNodeDescriptor>(diffs.size()); selected = new ArrayList<AVMNodeDescriptor>(diffs.size());
for (AVMDifference diff : diffs) for (AVMDifference diff : diffs)
{ {
@@ -356,8 +378,8 @@ public class SubmitDialog extends BaseDialogBean
{ {
if (hasAssociatedWorkflow(AVMNodeConverter.ToNodeRef(-1, node.getPath())) == false) if (hasAssociatedWorkflow(AVMNodeConverter.ToNodeRef(-1, node.getPath())) == false)
{ {
// TODO: lookup if this item was created via a FORM - then need to lookup the workflow defaults // lookup if this item was created via a frm - then lookup the workflow defaults
// for that form (and associated artifacts!) and then save that in list of workflows // for that form and store into the list of available workflows
NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath()); NodeRef ref = AVMNodeConverter.ToNodeRef(-1, node.getPath());
if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) if (this.nodeService.hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{ {
@@ -399,24 +421,13 @@ public class SubmitDialog extends BaseDialogBean
*/ */
private NodeRef createWorkflowPackage() private NodeRef createWorkflowPackage()
{ {
// TODO: add to common util class for all AVM workflows
String packagesRoot = "workflow-system:/packages";
AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesRoot);
if (packagesDesc == null)
{
avmService.createAVMStore("workflow-system");
avmService.createDirectory("workflow-system:/", "packages");
}
List<ItemWrapper> items = getSubmitItems(); List<ItemWrapper> items = getSubmitItems();
// create package paths (layered to user sandbox area as target) // create package paths (layered to user sandbox area as target)
String sandboxPath = AVMConstants.buildAVMStoreRootPath(avmBrowseBean.getSandbox()); String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox());
String packageName = GUID.generate(); String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, sandboxPath);
String packagesPath = packagesRoot + "/" + packageName;
avmService.createLayeredDirectory(sandboxPath, packagesRoot, packageName);
// construct diffs for selected items // construct diffs for selected items for submission
List<AVMDifference> diffs = new ArrayList<AVMDifference>(this.submitItems.size()); List<AVMDifference> diffs = new ArrayList<AVMDifference>(this.submitItems.size());
for (ItemWrapper wrapper : this.submitItems) for (ItemWrapper wrapper : this.submitItems)
{ {
@@ -427,12 +438,13 @@ public class SubmitDialog extends BaseDialogBean
} }
// write changes to layer so files are marked as modified // write changes to layer so files are marked as modified
avmSyncService.update(diffs, null, true, true, false, false, null, null); this.avmSyncService.update(diffs, null, true, true, false, false, null, null);
// convert package to workflow package // convert package to workflow package
AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath); AVMNodeDescriptor packageDesc = this.avmService.lookup(-1, packagesPath);
NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); NodeRef packageNodeRef = this.workflowService.createPackage(
nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath()));
this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true);
return packageNodeRef; return packageNodeRef;
} }

View File

@@ -178,8 +178,7 @@ public class WorkflowUtil
// marshal the properties and associations captured by the property sheet // marshal the properties and associations captured by the property sheet
// back into a Map to pass to the workflow service // back into a Map to pass to the workflow service
// go through all the properties in the transient node and add them to // go through all the properties in the transient node and add them to params map
// params map
Map<String, Object> props = node.getProperties(); Map<String, Object> props = node.getProperties();
for (String propName : props.keySet()) for (String propName : props.keySet())
{ {

View File

@@ -47,6 +47,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.NameMatcher;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
@@ -490,8 +491,9 @@ public class UIUserSandboxes extends SelfRenderingComponent
String id = getClientId(fc); String id = getClientId(fc);
// use the sync service to get the list of diffs between the stores // use the sync service to get the list of diffs between the stores
// TODO Need to pass the global exclude NameMatcher. NameMatcher matcher = (NameMatcher)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean(
List<AVMDifference> diffs = avmSyncService.compare(-1, userStore, -1, stagingStore, null); "globalPathExcluder");
List<AVMDifference> diffs = avmSyncService.compare(-1, userStore, -1, stagingStore, matcher);
if (diffs.size() != 0) if (diffs.size() != 0)
{ {
// store lookup of username to list of modified nodes // store lookup of username to list of modified nodes

View File

@@ -2753,6 +2753,10 @@
<property-name>nodeService</property-name> <property-name>nodeService</property-name>
<value>#{NodeService}</value> <value>#{NodeService}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>nameMatcher</property-name>
<value>#{globalPathExcluder}</value>
</managed-property>
</managed-bean> </managed-bean>
<!-- ==================== COMPONENT GENERATOR BEANS ==================== --> <!-- ==================== COMPONENT GENERATOR BEANS ==================== -->

View File

@@ -127,7 +127,7 @@
<td width="85%"> <td width="85%">
</f:verbatim> </f:verbatim>
<h:inputText id="webapp" value="#{WizardManager.bean.webapp}" size="35" maxlength="256" <h:inputText id="webapp" value="#{WizardManager.bean.webapp}" size="35" maxlength="256"
disabled="#{WizardManager.bean.editMode}" /> disabled="true" /> <%-- disabled="#{WizardManager.bean.editMode}" --%>
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>

View File

@@ -23,6 +23,17 @@
<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> <%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %> <%@ page isELIgnored="false" %>
<f:verbatim>
<script type="text/javascript">
window.onload = pageLoaded;
function pageLoaded()
{
document.getElementById("dialog:dialog-body:comment").focus();
}
</script>
</f:verbatim>
<h:panelGrid columns="1" cellpadding="2" style="padding-top:4px;padding-bottom:4px;" <h:panelGrid columns="1" cellpadding="2" style="padding-top:4px;padding-bottom:4px;"
width="100%" rowClasses="wizardSectionHeading"> width="100%" rowClasses="wizardSectionHeading">
<h:outputText value="&nbsp;#{msg.submit_submission_info}" escape="false" /> <h:outputText value="&nbsp;#{msg.submit_submission_info}" escape="false" />